Skip to content

Commit bba7458

Browse files
committed
feat(app): request config option to disable toast
1 parent e19034d commit bba7458

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/domain/profile/repository.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async function fetchFollowedList(params = {}) {
9595
}
9696

9797
async function fetchFollowedStatus(uid) {
98-
return httpClient.get(`/user/follow/${uid}`);
98+
return httpClient.get(`/user/follow/${uid}`, { noToast: true });
9999
}
100100

101101
async function followUser(uid) {

src/entry/aspects/http.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import httpClient, { legacyClient } from '@/utils/http';
2020

2121
let alreadySet = false;
2222

23-
function handleResponse(res) {
24-
if (!res.success) {
23+
function handleResponse(res, config) {
24+
if (!res.success && config.noToast !== true) {
2525
toast.error(res.message);
2626
}
2727

src/shared/types/http.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ type RequestConfig = RequestInit & {
3030
params?: Record<string, DataValue>;
3131
isServer?: boolean;
3232
type?: 'upload';
33+
noToast?: boolean;
3334
};
3435

35-
type ResponseInterceptor = (res: ResponseResult) => ResponseResult;
36+
type ResponseInterceptor = (res: ResponseResult, config: RequestConfig) => ResponseResult;
3637

3738
export type { ResponseResult, RequestConfig, ResponseInterceptor };

src/shared/utils/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function HttpClient(this: any, { baseUrl }: { baseUrl?: string }) { // eslint-di
119119
const res = await request(url, method, data, { ...config, baseUrl, isServer: isServerSide(config?.isServer) });
120120
const normalized = await normalizeResponse(res);
121121

122-
return resInterceptor ? resInterceptor(normalized) : normalized;
122+
return resInterceptor ? resInterceptor(normalized, config || {}) : normalized;
123123
};
124124
}
125125

0 commit comments

Comments
 (0)