Skip to content

Commit

Permalink
feat: replace UNDEFINED with void 0
Browse files Browse the repository at this point in the history
  • Loading branch information
surmon-china committed Sep 10, 2024
1 parent 26bb049 commit 91b6b2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/pages/index/twitter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ref, shallowRef } from 'vue'
import { useEnhancer } from '/@/app/enhancer'
import { VALUABLE_LINKS } from '/@/config/app.config'
import { UNDEFINED } from '/@/constants/value'
import { GAEventCategories } from '/@/constants/gtag'
import SwiperClass, { Swiper, SwiperSlide } from '/@/effects/swiper'
import { unescape, padStart, numberSplit } from '/@/transforms/text'
Expand Down Expand Up @@ -36,7 +37,7 @@

<template>
<div class="twitter">
<placeholder :data="profile ?? void 0" :loading="fetching">
<placeholder :data="profile ?? UNDEFINED" :loading="fetching">
<template #placeholder>
<empty class="twitter-empty" bold key="empty" />
</template>
Expand Down
17 changes: 9 additions & 8 deletions src/server/getters/twitter/sotwe-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios, { isAxiosError } from '@/server/services/axios'
import { WEB_SCRAPER_TOKEN } from '@/config/bff.yargs'
import { UNDEFINED } from '/@/constants/value'
import { isNodeDev } from '@/server/environment'
import type { TwitterTweet, TwitterProfile, TwitterAggregate } from './index'

Expand Down Expand Up @@ -129,11 +130,11 @@ export const getSotweTwitterAggregate = async (twitterUsername: string): Promise
id: sotwe?.info?.id,
name: sotwe?.info?.name || twitterUsername,
avatar: sotwe?.info?.profileImageOriginal || '',
description: sotwe?.info.description || void 0,
location: sotwe?.info.location || void 0,
tweetCount: sotwe?.info.postCount ?? void 0,
followerCount: sotwe?.info.followerCount ?? void 0,
followingCount: sotwe?.info.followingCount ?? void 0
description: sotwe?.info.description || UNDEFINED,
location: sotwe?.info.location || UNDEFINED,
tweetCount: sotwe?.info.postCount ?? UNDEFINED,
followerCount: sotwe?.info.followerCount ?? UNDEFINED,
followingCount: sotwe?.info.followingCount ?? UNDEFINED
}

// sotwe all tweets
Expand Down Expand Up @@ -167,9 +168,9 @@ export const getSotweTwitterAggregate = async (twitterUsername: string): Promise
text: improveSotweTweet(tweet),
html: improveSotweTweet(tweet),
date: tweet.createdAt,
location: tweet.location?.name || void 0,
favoriteCount: tweet.favoriteCount ?? void 0,
retweetCount: tweet.retweetCount ?? void 0,
location: tweet.location?.name || UNDEFINED,
favoriteCount: tweet.favoriteCount ?? UNDEFINED,
retweetCount: tweet.retweetCount ?? UNDEFINED,
mediaCount: tweet.mediaEntities?.length ?? 0,
isReply: !!tweet.inReplyToUserId,
isQuote: !!tweet.quotedStatus,
Expand Down

0 comments on commit 91b6b2a

Please sign in to comment.