fix(linktree) : followers count gone
This commit is contained in:
+17
-22
@@ -1,4 +1,3 @@
|
||||
import { unstable_cache } from "next/cache";
|
||||
import { getYoutubeSubscriberCount } from "./youtube";
|
||||
import { getRobloxFollowerCount } from "./roblox";
|
||||
import { getDiscordMemberCount } from "./discord";
|
||||
@@ -17,27 +16,23 @@ export interface FetchResult {
|
||||
tiktokProfile: TiktokProfile;
|
||||
}
|
||||
|
||||
const getFollowerCountsFromAPIs = unstable_cache(
|
||||
async (): Promise<FetchResult> => {
|
||||
const [youtube, roblox, discord, tiktokProfileResult] = await Promise.all([
|
||||
getYoutubeSubscriberCount(),
|
||||
getRobloxFollowerCount(),
|
||||
getDiscordMemberCount(),
|
||||
getTiktokProfile(),
|
||||
]);
|
||||
async function fetchFollowerCountsFromAPIs(): Promise<FetchResult> {
|
||||
const [youtube, roblox, discord, tiktokProfileResult] = await Promise.all([
|
||||
getYoutubeSubscriberCount(),
|
||||
getRobloxFollowerCount(),
|
||||
getDiscordMemberCount(),
|
||||
getTiktokProfile(),
|
||||
]);
|
||||
|
||||
const counts: FollowerCounts = {
|
||||
youtube,
|
||||
roblox,
|
||||
discord,
|
||||
tiktok: tiktokProfileResult.followerCount,
|
||||
};
|
||||
|
||||
return { counts, tiktokProfile: tiktokProfileResult };
|
||||
},
|
||||
['follower-counts-api'],
|
||||
{ revalidate: 3600, tags: ['follower-counts-api'] }
|
||||
);
|
||||
const counts: FollowerCounts = {
|
||||
youtube,
|
||||
roblox,
|
||||
discord,
|
||||
tiktok: tiktokProfileResult.followerCount,
|
||||
};
|
||||
|
||||
return { counts, tiktokProfile: tiktokProfileResult };
|
||||
}
|
||||
|
||||
export async function getFollowerCounts(): Promise<FetchResult> {
|
||||
try {
|
||||
@@ -57,7 +52,7 @@ export async function getFollowerCounts(): Promise<FetchResult> {
|
||||
// Redis unavailable, fall through to fetch
|
||||
}
|
||||
|
||||
const result = await getFollowerCountsFromAPIs();
|
||||
const result = await fetchFollowerCountsFromAPIs();
|
||||
|
||||
try {
|
||||
const { getRedisClient } = await import("@/lib/redis");
|
||||
|
||||
Reference in New Issue
Block a user