Skip to content

Commit 9370d24

Browse files
authored
Merge pull request #44 from LinkyBoard/dev
[WEB] 배포 최신화
2 parents d923451 + 6099eb2 commit 9370d24

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

apps/extension/src/lib/tanstack/mutation/content.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import {
88
quickSaveYoutubeContent,
99
updateContent,
1010
} from "@/services/content";
11-
import { successToast } from "@linkyboard/components";
11+
import { infoToast, successToast } from "@linkyboard/components";
1212
import { useMutation } from "@tanstack/react-query";
1313

14+
import type { HTTPError } from "ky";
15+
1416
import { invalidateQueries } from "..";
1517

1618
export const useQuickSaveContent = () => {
@@ -22,8 +24,10 @@ export const useQuickSaveContent = () => {
2224
invalidateQueries([CONTENT.GET_ALL_CONTENTS]);
2325
}
2426
},
25-
onError: (error) => {
26-
console.error(error);
27+
onError: (error: HTTPError) => {
28+
if (error.response.status === 401) {
29+
infoToast("세션이 만료되었어요. 다시 로그인해주세요.");
30+
}
2731
},
2832
});
2933
};
@@ -37,23 +41,32 @@ export const useQuickSaveYoutubeContent = () => {
3741
invalidateQueries([CONTENT.GET_ALL_CONTENTS]);
3842
}
3943
},
44+
onError: (error: HTTPError) => {
45+
if (error.response.status === 401) {
46+
infoToast("세션이 만료되었어요. 다시 로그인해주세요.");
47+
}
48+
},
4049
});
4150
};
4251

4352
export const useDetailSaveContent = () => {
4453
return useMutation({
4554
mutationFn: detailSaveWebContent,
46-
onError: (error) => {
47-
console.error(error);
55+
onError: (error: HTTPError) => {
56+
if (error.response.status === 401) {
57+
infoToast("세션이 만료되었어요. 다시 로그인해주세요.");
58+
}
4859
},
4960
});
5061
};
5162

5263
export const useDetailSaveYoutubeContent = () => {
5364
return useMutation({
5465
mutationFn: detailSaveYoutubeContent,
55-
onError: (error) => {
56-
console.error(error);
66+
onError: (error: HTTPError) => {
67+
if (error.response.status === 401) {
68+
infoToast("세션이 만료되었어요. 다시 로그인해주세요.");
69+
}
5770
},
5871
});
5972
};

apps/extension/src/services/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { removeCookie } from "@/utils/cookie";
1+
import { getCookie, removeCookie } from "@/utils/cookie";
22
import { infoToast } from "@linkyboard/components";
33

44
import ky, { type KyRequest, type KyResponse } from "ky";
@@ -17,11 +17,12 @@ export const api = ky.create({
1717
hooks: {
1818
afterResponse: [
1919
async (request: KyRequest, _, response: KyResponse) => {
20-
if (response.status === 401) {
20+
const token = await getCookie("accessToken");
21+
22+
if (response.status === 401 && token) {
2123
infoToast("세션이 만료되었어요. 다시 로그인해주세요.");
2224
removeCookie("accessToken");
2325
removeCookie("refreshToken");
24-
return window.location.replace("/");
2526
}
2627

2728
return response;

apps/web/src/components/(with-side-bar)/layout/recent-topic-list.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ export default function RecentTopicList() {
3232
close(); // 모바일에서 사이드바 닫기
3333
};
3434

35-
const isSelected = (topicId: number) =>
36-
pathname.includes("topic") && pathname.includes(topicId.toString());
35+
const isSelected = (topicId: number) => {
36+
const topicPath = `/topic/${topicId}`;
37+
return pathname === topicPath || pathname.startsWith(`${topicPath}/`);
38+
};
3739

3840
useEffect(() => {
3941
if (!isPending) {

0 commit comments

Comments
 (0)