8000 Merge pull request #195 from junhoyeo/junhoyeo/quick-fixes-to-landing · enggaraziz/threads-api@eda8fb7 · GitHub
[go: up one dir, main page]

Skip to content

Commit eda8fb7

Browse files
authored
Merge pull request junhoyeo#195 from junhoyeo/junhoyeo/quick-fixes-to-landing
web-ui(landing): Revalidate stargazers count every 60 seconds, Add missing link
2 parents e15769f + 4ed7bc2 commit eda8fb7

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

threads-web-ui/app/[username]/page.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import { threadsAPI } from '@/lib/api';
12
import Image from 'next/image';
23
import Link from 'next/link';
34
import React from 'react';
45
import { Thread, ThreadsIcons } from 'react-threads';
5-
import { Thread as ThreadType, ThreadsAPI, ThreadsUser } from 'threads-api';
6-
7-
const threadsAPI = new ThreadsAPI({ verbose: true });
6+
import { Thread as ThreadType, ThreadsUser } from 'threads-api';
87

98
const UserProfilePage = async ({ params }: { params: { username: string } }) => {
109
const username = params.username;

threads-web-ui/app/page.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import { Globe } from '@/components/Globe';
55
import './globals.css';
66

77
const getStargazersCount = async (): Promise<number> => {
8-
// https://api.github.com/repos/junhoyeo/threads-api
9-
const res = await fetch('https://api.github.com/repos/junhoyeo/threads-api');
8+
const res = await fetch('https://api.github.com/repos/junhoyeo/threads-api', {
9+
next: { revalidate: 60 },
10+
});
1011
const data = await res.json();
1112
return data.stargazers_count;
1213
};
@@ -61,9 +62,11 @@ export default async function Home() {
6162
<Star className="text-zinc-900 fill-zinc-900" size={14} /> {stargazersCount.toLocaleString()}
6263
</span>
6364
</div>
64-
<button className="mt-3 px-8 py-4 rounded-[16px] bg-black shadow-xl shadow-slate-900/20 text-slate-300">
65-
View on GitHub
66-
</button>
65+
<a href="https://github.com/junhoyeo/threads-api">
66+
<button className="mt-3 px-8 py-4 rounded-[16px] bg-black shadow-xl shadow-slate-900/20 text-slate-300">
67+
View on GitHub
68+
</button>
69+
</a>
6770
</div>
6871

6972
<div className="mt-[-200px] mb-[-156px] z-10 opacity-40 relative">
@@ -73,7 +76,7 @@ export default async function Home() {
7376
</div>
7477
</div>
7578

76-
<ul className="z-10 flex w-full max-w-4xl gap-2">
79+
<ul className="z-10 flex w-full max-w-4xl gap-2 px-5">
7780
<li className="flex-1 p-4 border rounded-xl bg-zinc-900 border-zinc-800 text-slate-200">
7881
<BookOpen /> <h3 className="mt-3 text-lg font-medium">Read Data</h3>
7982
</li>

threads-web-ui/app/post/[threadOrPostID]/page.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1+
import { threadsAPI } from '@/lib/api';
12
import React from 'react';
23
import { Thread } from 'react-threads';
3-
import { ThreadsAPI } from 'threads-api';
4-
5-
const threadsAPI = new ThreadsAPI({ verbose: true });
64

75
const ThreadDetailPage = async ({ params }: { params: { threadOrPostID: string } }) => {
86
const threadID = params?.threadOrPostID;
@@ -26,9 +24,7 @@ const ThreadDetailPage = async ({ params }: { params: { threadOrPostID: string }
2624
<div className="w-full h-[120px] rounded-[8px] animate-pulse bg-[rgba(243,245,247,0.05)]" />
2725
)}
2826

29-
{thread.reply_threads?.map((thread) => (
30-
<Thread key={thread.id} thread={thread} />
31-
))}
27+
{thread.reply_threads?.map((thread) => <Thread key={thread.id} thread={thread} />)}
3228
</main>
3329
</div>
3430
);

threads-web-ui/lib/api.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ThreadsAPI } from 'threads-api';
2+
3+
export const threadsAPI = new ThreadsAPI({
4+
verbose: true,
5+
deviceID: 'android-1aeltfp3omyo0000',
6+
});

0 commit comments

Comments
 (0)
0