From fa36bb8ac615e8d8a8db34b029f0aed3da0b13c1 Mon Sep 17 00:00:00 2001 From: sajjad isvand Date: Sat, 4 Jul 2026 23:03:20 +0330 Subject: [PATCH 1/6] fix --- .../habit/components/item/button.simple-progress-ring.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/widgets/habit/components/item/button.simple-progress-ring.tsx b/src/layouts/widgets/habit/components/item/button.simple-progress-ring.tsx index 3ed82e79..a2e712a8 100644 --- a/src/layouts/widgets/habit/components/item/button.simple-progress-ring.tsx +++ b/src/layouts/widgets/habit/components/item/button.simple-progress-ring.tsx @@ -26,7 +26,7 @@ export function SimpleProgressRing({ cy={center} r={radius} fill="none" - stroke="#d1d5db" + className={'stroke-base-200'} strokeWidth={strokeWidth} opacity={0.3} /> From fa5d47273860f645487da6e6c964b5b995eef6f4 Mon Sep 17 00:00:00 2001 From: sajjad isvand Date: Sat, 4 Jul 2026 23:04:40 +0330 Subject: [PATCH 2/6] change icon --- src/layouts/widgets/news/components/news-header.tsx | 3 +-- src/layouts/widgets/wigiArz/components/arz-header.tsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/layouts/widgets/news/components/news-header.tsx b/src/layouts/widgets/news/components/news-header.tsx index 49dac729..feacb330 100644 --- a/src/layouts/widgets/news/components/news-header.tsx +++ b/src/layouts/widgets/news/components/news-header.tsx @@ -11,7 +11,6 @@ export const NewsHeader = ({ title, onSettingsClick }: NewsHeaderProps) => {
-

{title}

@@ -23,7 +22,7 @@ export const NewsHeader = ({ title, onSettingsClick }: NewsHeaderProps) => { className="h-6 w-6 p-0 flex items-center justify-center rounded-full !border-none !shadow-none" > diff --git a/src/layouts/widgets/wigiArz/components/arz-header.tsx b/src/layouts/widgets/wigiArz/components/arz-header.tsx index 215b288b..7c07002f 100644 --- a/src/layouts/widgets/wigiArz/components/arz-header.tsx +++ b/src/layouts/widgets/wigiArz/components/arz-header.tsx @@ -20,7 +20,7 @@ export const ArzHeader = ({ title, onSettingsClick }: ArzHeaderProps) => { className="h-6 w-6 p-0 flex items-center justify-center rounded-full !border-none !shadow-none" > From fb47ca1bdacb471f2386ee14f8cf5dd17b00baf2 Mon Sep 17 00:00:00 2001 From: sajjad isvand Date: Sat, 4 Jul 2026 23:07:15 +0330 Subject: [PATCH 3/6] fix news scrollbar --- src/layouts/widgets/news/components/news-container.tsx | 2 +- src/layouts/widgets/news/news.layout.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layouts/widgets/news/components/news-container.tsx b/src/layouts/widgets/news/components/news-container.tsx index f7ce96be..a3f54540 100644 --- a/src/layouts/widgets/news/components/news-container.tsx +++ b/src/layouts/widgets/news/components/news-container.tsx @@ -18,7 +18,7 @@ export const NewsContainer = ({ customFeeds, useDefaultNews }: NewsContainerProp } return ( -
+
{enabledFeeds.map((feed) => ( ))} diff --git a/src/layouts/widgets/news/news.layout.tsx b/src/layouts/widgets/news/news.layout.tsx index 1c6937be..3dd2f463 100644 --- a/src/layouts/widgets/news/news.layout.tsx +++ b/src/layouts/widgets/news/news.layout.tsx @@ -59,7 +59,7 @@ export const NewsLayout: React.FC = ({ ) : ( Date: Sat, 4 Jul 2026 23:21:38 +0330 Subject: [PATCH 4/6] refactor(api): use env API_URL and singleton refresh token handler --- src/services/api.ts | 106 +++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 40 deletions(-) diff --git a/src/services/api.ts b/src/services/api.ts index d3f4dc04..8ddab1b1 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -7,53 +7,59 @@ import axios, { import { getFromStorage, setToStorage } from '@/common/storage' import { callEvent } from '@/common/utils/call-event' -const rawGithubApi = axios.create({ - baseURL: 'https://raw.githubusercontent.com/sajjadmrx/btime-desktop/main', -}) -export let API_URL = '' -export async function getMainClient(): Promise { - let instance: AxiosInstance | undefined +export const API_URL = import.meta.env.VITE_API + +const VERSION = browser.runtime.getManifest().version + +const IGNORE_ENDPOINTS = [ + '/auth/signin', + '/auth/signup', + '/auth/otp', + '/auth/otp/verify', + '/auth/oauth/google', +] - const token = await getFromStorage('auth_token') - API_URL = import.meta.env.VITE_API +let instance: AxiosInstance | null = null +let refreshPromise: Promise | null = null + +export async function getMainClient(): Promise { + if (instance) { + return instance + } if (!API_URL) { - const urlResponse = await rawGithubApi.get('/.github/api.txt') - API_URL = urlResponse.data + throw new Error('API base URL is not defined') } instance = axios.create({ baseURL: API_URL, headers: { - Authorization: token ? `Bearer ${token}` : undefined, client: 'widgetify-extension', - version: browser.runtime.getManifest().version, + version: VERSION, }, }) - if (!instance) { - throw new Error('API base URL is not defined') - } + instance.interceptors.request.use(async (config) => { + const token = await getFromStorage('auth_token') + + if (token) { + config.headers.Authorization = `Bearer ${token}` + } else { + delete config.headers.Authorization + } + + return config + }) - // Response interceptor to handle token refreshing instance.interceptors.response.use( - (response: AxiosResponse) => { - return response - }, + (response: AxiosResponse) => response, async (error: AxiosError) => { const originalRequest = error.config as InternalAxiosRequestConfig & { _retry?: boolean } - const ignoreEndpoints = [ - '/auth/signin', - '/auth/signup', - '/auth/otp', - '/auth/otp/verify', - '/auth/oauth/google', - ] if ( - ignoreEndpoints.some((endpoint) => + IGNORE_ENDPOINTS.some((endpoint) => originalRequest.url?.includes(endpoint) ) ) { @@ -62,29 +68,49 @@ export async function getMainClient(): Promise { if (error.response?.status === 401 && !originalRequest._retry) { originalRequest._retry = true + try { - const refresh_token: string | null = - await getFromStorage('refresh_token') + if (!refreshPromise) { + refreshPromise = (async () => { + const refreshToken = await getFromStorage('refresh_token') + + if (!refreshToken) { + return null + } + + const response = await axios.post(`${API_URL}/auth/refresh`, { + refresh_token: refreshToken, + }) - if (!refresh_token) { - return + const newToken = response.data.data + + if (!newToken) { + return null + } + + await setToStorage('auth_token', newToken) + + return newToken + })() + + refreshPromise.finally(() => { + refreshPromise = null + }) } - const response = await axios.post(`${API_URL}/auth/refresh`, { - refresh_token, - }) + const newToken = await refreshPromise - const newToken = response.data.data - if (newToken) { - await setToStorage('auth_token', newToken) - originalRequest.headers.Authorization = `Bearer ${newToken}` - } else { + if (!newToken) { callEvent('auth_logout', null) + return Promise.reject(error) } - return instance(originalRequest) + originalRequest.headers.Authorization = `Bearer ${newToken}` + + return instance!(originalRequest) } catch (_refreshError) { callEvent('auth_logout', null) + return Promise.reject(error) } } From 88141b728c077418da22ca84a454e12777872a79 Mon Sep 17 00:00:00 2001 From: sajjad isvand Date: Sat, 4 Jul 2026 23:22:03 +0330 Subject: [PATCH 5/6] fix --- src/services/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/api.ts b/src/services/api.ts index 8ddab1b1..595fbfb5 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -7,7 +7,7 @@ import axios, { import { getFromStorage, setToStorage } from '@/common/storage' import { callEvent } from '@/common/utils/call-event' -export const API_URL = import.meta.env.VITE_API +export const API_URL = import.meta.env.VITE_API || 'https://api.widgetify.ir' const VERSION = browser.runtime.getManifest().version From 318f5efacb418cd7dda82d809ae613017fadff5b Mon Sep 17 00:00:00 2001 From: sajjad isvand Date: Sat, 4 Jul 2026 23:28:01 +0330 Subject: [PATCH 6/6] refactor: remove unnecessary await calls for getMainClient --- src/components/updater/updater.tsx | 2 +- src/layouts/navbar/sync.tsx | 2 +- .../search/image/image-search.portal.tsx | 2 +- .../user-profile/connections/connections.tsx | 4 ++-- .../widgets/network/network.layout.tsx | 4 ++-- src/services/api.ts | 2 +- src/services/config-data/config_data-api.ts | 2 +- src/services/emoji/emoji-api.ts | 2 +- src/services/hooks/auth/authService.hook.ts | 18 +++++++-------- .../hooks/bookmark/add-bookmark.hook.ts | 2 +- .../hooks/bookmark/getBookmarks.hook.ts | 4 ++-- .../hooks/bookmark/remove-bookmark.hook.ts | 2 +- .../bookmark/update-bookmark-order.hook.ts | 2 +- .../hooks/bookmark/update-bookmark.hook.ts | 2 +- .../hooks/calendar/get-calendarData.hook.ts | 2 +- src/services/hooks/cities/getCitiesList.ts | 2 +- .../hooks/content/get-content.hook.ts | 2 +- .../hooks/currency/getCurrencyByCode.hook.ts | 2 +- .../currency/getSupportCurrencies.hook.ts | 2 +- src/services/hooks/date/getEvents.hook.ts | 2 +- .../date/getGoogleCalendarEvents.hook.ts | 2 +- .../hooks/date/getReligiousTime.hook.ts | 2 +- .../hooks/extension/getNotifications.hook.ts | 4 ++-- .../hooks/extension/updateSetting.hook.ts | 16 +++++++------- .../hooks/friends/friendService.hook.ts | 22 +++++++++---------- src/services/hooks/getDailyMessage.hook.ts | 8 ++----- src/services/hooks/habit/add-habit.hook.ts | 2 +- .../hooks/habit/archive-habit.hook.ts | 2 +- .../hooks/habit/get-habit-detail.hook.ts | 2 +- src/services/hooks/habit/get-habits.hook.ts | 2 +- .../hooks/habit/log-habit-progress.hook.ts | 2 +- src/services/hooks/habit/update-habit.hook.ts | 2 +- .../hooks/market/getMarketItems.hook.ts | 2 +- .../hooks/market/getUserInventory.hook.ts | 2 +- .../hooks/market/market-coints.hook.ts | 4 ++-- .../hooks/market/purchaseMarketItem.hook.ts | 2 +- .../hooks/mini-apps/get-mini-app.hook.ts | 2 +- .../hooks/mini-apps/get-mini-apps.hook.ts | 2 +- .../hooks/mini-apps/launch-mini-app.hook.ts | 2 +- src/services/hooks/moodLog/get-moods.hook.ts | 2 +- .../hooks/moodLog/upsert-moodLog.hook.ts | 2 +- src/services/hooks/news/getNews.hook.ts | 4 ++-- src/services/hooks/note/delete-note.hook.ts | 2 +- src/services/hooks/note/get-notes.hook.ts | 2 +- src/services/hooks/note/upsert-note.hook.ts | 2 +- .../hooks/pomodoro/createSession.hook.ts | 2 +- .../hooks/pomodoro/getTopUsers.hook.ts | 2 +- .../hooks/profile/getProfileMeta.hook.ts | 2 +- .../hooks/search/getSuggestSearch.hook.ts | 11 ++++++---- .../hooks/timezone/getTimezones.hook.ts | 2 +- src/services/hooks/todo/add-todo.hook.ts | 2 +- src/services/hooks/todo/get-tags.hook.ts | 2 +- src/services/hooks/todo/get-todos.hook.ts | 2 +- src/services/hooks/todo/remove-todo.hook.ts | 2 +- src/services/hooks/todo/reorder-todo.hook.ts | 2 +- src/services/hooks/todo/update-todo.hook.ts | 2 +- .../hooks/translate/translateService.ts | 4 ++-- src/services/hooks/trends/getTrends.ts | 2 +- .../hooks/user/referralsService.hook.ts | 4 ++-- src/services/hooks/user/userService.hook.ts | 22 +++++++++---------- .../wallpapers/getWallpaperCategories.hook.ts | 10 ++++----- .../wallpapers/getWallpaperPreviewUrl.hook.ts | 2 +- .../weather/getForecastWeatherByLatLon.ts | 2 +- .../hooks/weather/getRelatedCities.ts | 2 +- .../hooks/weather/getWeatherByLatLon.ts | 2 +- 65 files changed, 119 insertions(+), 120 deletions(-) diff --git a/src/components/updater/updater.tsx b/src/components/updater/updater.tsx index db7456a1..6aa64b2d 100644 --- a/src/components/updater/updater.tsx +++ b/src/components/updater/updater.tsx @@ -8,7 +8,7 @@ let updateInfo = null async function checkForUpdates() { try { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/extension/version') const currentVersion = browser.runtime.getManifest().version diff --git a/src/layouts/navbar/sync.tsx b/src/layouts/navbar/sync.tsx index d4f35a6d..9ab358ff 100644 --- a/src/layouts/navbar/sync.tsx +++ b/src/layouts/navbar/sync.tsx @@ -30,7 +30,7 @@ export function SyncAccount() { async function getAll() { try { - const client = await getMainClient() + const client = getMainClient() const response = await client.get<{ wallpaper: Wallpaper theme: Theme | null diff --git a/src/layouts/search/image/image-search.portal.tsx b/src/layouts/search/image/image-search.portal.tsx index 0d7ff85a..3db346d2 100644 --- a/src/layouts/search/image/image-search.portal.tsx +++ b/src/layouts/search/image/image-search.portal.tsx @@ -44,7 +44,7 @@ export function ImageSearchPortal({ const formData = new FormData() formData.append('image', file) - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/users/@me/upload/search', formData, { headers: { 'Content-Type': 'multipart/form-data', diff --git a/src/layouts/setting/tabs/account/tabs/user-profile/connections/connections.tsx b/src/layouts/setting/tabs/account/tabs/user-profile/connections/connections.tsx index e7e036a8..587f5ebe 100644 --- a/src/layouts/setting/tabs/account/tabs/user-profile/connections/connections.tsx +++ b/src/layouts/setting/tabs/account/tabs/user-profile/connections/connections.tsx @@ -62,7 +62,7 @@ export function Connections() { try { if (selectedPlatform.connected) { - const api = await getMainClient() + const api = getMainClient() await api.post(`/${selectedPlatform.id}/disconnect`) setPlatforms((prev) => @@ -75,7 +75,7 @@ export function Connections() { showToast(`اتصال به ${selectedPlatform.name} قطع شد.`, 'success') } else { - const api = await getMainClient() + const api = getMainClient() const response = await api.post(`/${selectedPlatform.id}/connect`) window.location.href = response.data.url diff --git a/src/layouts/widgets/network/network.layout.tsx b/src/layouts/widgets/network/network.layout.tsx index f71f2abb..c9ba0456 100644 --- a/src/layouts/widgets/network/network.layout.tsx +++ b/src/layouts/widgets/network/network.layout.tsx @@ -47,7 +47,7 @@ export function NetworkLayout({ enableBackground, inComboWidget }: Prop) { const fetchNetworkData = async () => { setIsLoading(true) try { - const client = await getMainClient() + const client = getMainClient() const response = await client.get('/extension/@me/ip') const data = response.data setNetworkInfo((prev) => ({ @@ -70,7 +70,7 @@ export function NetworkLayout({ enableBackground, inComboWidget }: Prop) { } try { - const client = await getMainClient() + const client = getMainClient() const start = Date.now() const [err, _ok] = await safeAwait(client.get('/')) if (err) { diff --git a/src/services/api.ts b/src/services/api.ts index 595fbfb5..5ce44a26 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -22,7 +22,7 @@ const IGNORE_ENDPOINTS = [ let instance: AxiosInstance | null = null let refreshPromise: Promise | null = null -export async function getMainClient(): Promise { +export function getMainClient(): AxiosInstance { if (instance) { return instance } diff --git a/src/services/config-data/config_data-api.ts b/src/services/config-data/config_data-api.ts index d1312d50..eafb997b 100644 --- a/src/services/config-data/config_data-api.ts +++ b/src/services/config-data/config_data-api.ts @@ -10,7 +10,7 @@ export interface ExtensionConfigResponse { } export async function getConfigData(): Promise { - const api = await getMainClient() + const api = getMainClient() const result = await api.get('/extension') diff --git a/src/services/emoji/emoji-api.ts b/src/services/emoji/emoji-api.ts index 8203c7de..d16f9135 100644 --- a/src/services/emoji/emoji-api.ts +++ b/src/services/emoji/emoji-api.ts @@ -7,7 +7,7 @@ interface EmojiResponse { export async function getEmojiList(): Promise { try { - const api = await getMainClient() + const api = getMainClient() const emojisRes = await api.get('/extension/emojis') diff --git a/src/services/hooks/auth/authService.hook.ts b/src/services/hooks/auth/authService.hook.ts index 053789d7..550af892 100644 --- a/src/services/hooks/auth/authService.hook.ts +++ b/src/services/hooks/auth/authService.hook.ts @@ -50,7 +50,7 @@ interface WizardPayload { } async function signIn(credentials: LoginCredentials): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/auth/signin', credentials) if (response.headers?.refresh_token) { @@ -61,7 +61,7 @@ async function signIn(credentials: LoginCredentials): Promise { } async function signUp(credentials: SignUpCredentials): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/auth/signup', credentials) if (response.headers?.refresh_token) { @@ -72,7 +72,7 @@ async function signUp(credentials: SignUpCredentials): Promise { } async function updateUserProfile(formData: FormData): Promise { - const api = await getMainClient() + const api = getMainClient() const response = await api.patch('/users/@me', formData, { headers: { 'Content-Type': 'multipart/form-data', @@ -82,7 +82,7 @@ async function updateUserProfile(formData: FormData): Promise { } async function updateUsername(username: string): Promise { - const api = await getMainClient() + const api = getMainClient() const response = await api.put('/users/@me/username', { username, }) @@ -90,7 +90,7 @@ async function updateUsername(username: string): Promise { } async function googleSignIn(credentials: GoogleAuthCredentials): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/auth/oauth/google', credentials) if (response.headers?.refresh_token) { @@ -101,7 +101,7 @@ async function googleSignIn(credentials: GoogleAuthCredentials): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/auth/otp', payload) @@ -109,7 +109,7 @@ async function requestOtp(payload: OtpPayload): Promise { } async function verifyOtp(payload: OtpVerifyPayload): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/auth/otp/verify', payload) if (response.headers?.refresh_token) { @@ -123,13 +123,13 @@ async function getAuthState(): Promise<{ content?: string type?: 'warning' | 'info' }> { - const client = await getMainClient() + const client = getMainClient() const response = await client.get('/auth/status') return response.data.data } async function setupWizard(data: WizardPayload): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/users/@me/complete-wizard', data) return response.data } diff --git a/src/services/hooks/bookmark/add-bookmark.hook.ts b/src/services/hooks/bookmark/add-bookmark.hook.ts index 2c5f4e69..b1255856 100644 --- a/src/services/hooks/bookmark/add-bookmark.hook.ts +++ b/src/services/hooks/bookmark/add-bookmark.hook.ts @@ -24,7 +24,7 @@ export const useAddBookmark = () => { } export async function AddBookmarkApi(input: BookmarkCreationPayload) { - const client = await getMainClient() + const client = getMainClient() const formData = new FormData() diff --git a/src/services/hooks/bookmark/getBookmarks.hook.ts b/src/services/hooks/bookmark/getBookmarks.hook.ts index 063aff69..6a63d7c2 100644 --- a/src/services/hooks/bookmark/getBookmarks.hook.ts +++ b/src/services/hooks/bookmark/getBookmarks.hook.ts @@ -47,13 +47,13 @@ export const useGetSuggestedBookmarks = () => { export async function getBookmarks(id: string | null): Promise { const params = id ? { id } : {} - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/bookmarks/@me', { params }) return data } export async function getSuggestedBookmarks(): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/bookmarks/suggestions') return data } diff --git a/src/services/hooks/bookmark/remove-bookmark.hook.ts b/src/services/hooks/bookmark/remove-bookmark.hook.ts index b58ab869..3689b287 100644 --- a/src/services/hooks/bookmark/remove-bookmark.hook.ts +++ b/src/services/hooks/bookmark/remove-bookmark.hook.ts @@ -5,7 +5,7 @@ export const useRemoveBookmark = () => { return useMutation({ mutationKey: ['removeBookmark'], mutationFn: async (bookmarkId: string) => { - const client = await getMainClient() + const client = getMainClient() await client.delete(`/bookmarks/${bookmarkId}`) }, }) diff --git a/src/services/hooks/bookmark/update-bookmark-order.hook.ts b/src/services/hooks/bookmark/update-bookmark-order.hook.ts index ad489ee3..c55158fe 100644 --- a/src/services/hooks/bookmark/update-bookmark-order.hook.ts +++ b/src/services/hooks/bookmark/update-bookmark-order.hook.ts @@ -10,7 +10,7 @@ export const useUpdateBookmarkOrder = () => { return useMutation({ mutationKey: ['updateBookmarkOrder'], mutationFn: async (input: BookmarkOrderUpdatePayload): Promise => { - const client = await getMainClient() + const client = getMainClient() await client.put('/bookmarks/order', input) }, diff --git a/src/services/hooks/bookmark/update-bookmark.hook.ts b/src/services/hooks/bookmark/update-bookmark.hook.ts index 565524c6..ba6d79d3 100644 --- a/src/services/hooks/bookmark/update-bookmark.hook.ts +++ b/src/services/hooks/bookmark/update-bookmark.hook.ts @@ -17,7 +17,7 @@ export const useUpdateBookmark = () => { return useMutation({ mutationKey: ['updateBookmark'], mutationFn: async (input: BookmarkUpdatePayload): Promise => { - const client = await getMainClient() + const client = getMainClient() const formData = new FormData() diff --git a/src/services/hooks/calendar/get-calendarData.hook.ts b/src/services/hooks/calendar/get-calendarData.hook.ts index d4b254f9..74ac6ee1 100644 --- a/src/services/hooks/calendar/get-calendarData.hook.ts +++ b/src/services/hooks/calendar/get-calendarData.hook.ts @@ -28,7 +28,7 @@ async function getCalendarData( start: string, end: string ): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get( `/widgets/calendar?start=${start}&end=${end}` ) diff --git a/src/services/hooks/cities/getCitiesList.ts b/src/services/hooks/cities/getCitiesList.ts index a9807531..613751e1 100644 --- a/src/services/hooks/cities/getCitiesList.ts +++ b/src/services/hooks/cities/getCitiesList.ts @@ -7,7 +7,7 @@ export interface CityResponse { } async function fetchCitiesList(): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.get('/cities/list') return response.data } diff --git a/src/services/hooks/content/get-content.hook.ts b/src/services/hooks/content/get-content.hook.ts index 3d776cf3..d1d0f046 100644 --- a/src/services/hooks/content/get-content.hook.ts +++ b/src/services/hooks/content/get-content.hook.ts @@ -48,7 +48,7 @@ export const useGetContents = () => { return useQuery({ queryKey: ['contents'], queryFn: async () => { - const api = await getMainClient() + const api = getMainClient() const { data } = await api.get('/contents') return data diff --git a/src/services/hooks/currency/getCurrencyByCode.hook.ts b/src/services/hooks/currency/getCurrencyByCode.hook.ts index a1b2ce03..77de643c 100644 --- a/src/services/hooks/currency/getCurrencyByCode.hook.ts +++ b/src/services/hooks/currency/getCurrencyByCode.hook.ts @@ -38,7 +38,7 @@ export const useGetCurrencyByCode = ( } async function getSupportCurrencies(currency: string): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get(`/currencies/${currency}`) return data } diff --git a/src/services/hooks/currency/getSupportCurrencies.hook.ts b/src/services/hooks/currency/getSupportCurrencies.hook.ts index 9549a6a7..0301e4a9 100644 --- a/src/services/hooks/currency/getSupportCurrencies.hook.ts +++ b/src/services/hooks/currency/getSupportCurrencies.hook.ts @@ -22,7 +22,7 @@ export const useGetSupportCurrencies = () => { } async function getSupportCurrencies(): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/currencies/supported-list') return data } diff --git a/src/services/hooks/date/getEvents.hook.ts b/src/services/hooks/date/getEvents.hook.ts index 8ce34ab2..91f72bb5 100644 --- a/src/services/hooks/date/getEvents.hook.ts +++ b/src/services/hooks/date/getEvents.hook.ts @@ -24,7 +24,7 @@ export const useGetEvents = () => { } async function getEvents(): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/date/events') return data ?? [] } diff --git a/src/services/hooks/date/getGoogleCalendarEvents.hook.ts b/src/services/hooks/date/getGoogleCalendarEvents.hook.ts index 7c990bdd..e58ebc54 100644 --- a/src/services/hooks/date/getGoogleCalendarEvents.hook.ts +++ b/src/services/hooks/date/getGoogleCalendarEvents.hook.ts @@ -92,7 +92,7 @@ async function getGoogleCalendarEvents( endDate?: string ): Promise { try { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get( `/google/events?start=${encodeURIComponent(startDate)}&end=${encodeURIComponent(endDate ?? '')}` ) diff --git a/src/services/hooks/date/getReligiousTime.hook.ts b/src/services/hooks/date/getReligiousTime.hook.ts index 6fc6a69d..ba5a5a12 100644 --- a/src/services/hooks/date/getReligiousTime.hook.ts +++ b/src/services/hooks/date/getReligiousTime.hook.ts @@ -33,7 +33,7 @@ export const useReligiousTime = (op: Prop, enabled: boolean) => { return useQuery({ queryKey: key, queryFn: async () => { - const client = await getMainClient() + const client = getMainClient() const { data: result } = await client.get( '/date/owghat', { diff --git a/src/services/hooks/extension/getNotifications.hook.ts b/src/services/hooks/extension/getNotifications.hook.ts index 3312f6ac..d0e579f5 100644 --- a/src/services/hooks/extension/getNotifications.hook.ts +++ b/src/services/hooks/extension/getNotifications.hook.ts @@ -51,7 +51,7 @@ export interface NotificationItemResponse { } async function fetchNotifications(): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get<{ data: NotificationItemResponse }>( '/extension/notifications' ) @@ -71,7 +71,7 @@ export function useGetNotifications() { export function useNotifyAsSeen() { return useMutation({ mutationFn: async (id: string) => { - const client = await getMainClient() + const client = getMainClient() await client.put(`/notifications/${id}/seen`) }, onSuccess: () => { diff --git a/src/services/hooks/extension/updateSetting.hook.ts b/src/services/hooks/extension/updateSetting.hook.ts index 840062e2..22ba0339 100644 --- a/src/services/hooks/extension/updateSetting.hook.ts +++ b/src/services/hooks/extension/updateSetting.hook.ts @@ -14,7 +14,7 @@ export interface UpdateExtensionSettingsInput { export function useUpdateExtensionSettings() { return useMutation({ mutationFn: async (data: UpdateExtensionSettingsInput) => { - const client = await getMainClient() + const client = getMainClient() await client.patch('/extension/@me', data) }, }) @@ -23,7 +23,7 @@ export function useUpdateExtensionSettings() { export function useChangeWallpaper() { return useMutation({ mutationFn: async ({ wallpaperId }) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.put<{ data: Wallpaper }>('/wallpapers/@me', { wallpaperId, }) @@ -35,7 +35,7 @@ export function useChangeWallpaper() { export function useChangeTheme() { return useMutation({ mutationFn: async ({ theme }) => { - const client = await getMainClient() + const client = getMainClient() await client.put('/extension/@me/theme', { theme }) }, }) @@ -44,7 +44,7 @@ export function useChangeTheme() { export function useChangeBrowserTitle() { return useMutation({ mutationFn: async ({ browserTitleId }) => { - const client = await getMainClient() + const client = getMainClient() await client.put('/extension/@me/browser-title', { browserTitleId }) }, }) @@ -53,7 +53,7 @@ export function useChangeBrowserTitle() { export function useChangeFont() { return useMutation({ mutationFn: async ({ font }) => { - const client = await getMainClient() + const client = getMainClient() await client.put('/extension/@me/font', { font }) }, }) @@ -62,7 +62,7 @@ export function useChangeFont() { export function useChangeUI() { return useMutation({ mutationFn: async ({ ui }) => { - const client = await getMainClient() + const client = getMainClient() await client.put('/extension/@me/ui', { ui }) }, }) @@ -71,7 +71,7 @@ export function useChangeUI() { export function useChangeSearchEngine() { return useMutation({ mutationFn: async ({ search_engine }) => { - const client = await getMainClient() + const client = getMainClient() await client.put('/extension/@me/search-engine', { search_engine }) }, }) @@ -82,7 +82,7 @@ export function useUpdateSearchAutocomplete() { return useMutation({ mutationFn: async ({ isActive }) => { - const client = await getMainClient() + const client = getMainClient() await client.put('/extension/@me/search-search-autocomplete', { isActive }) }, onSuccess: () => { diff --git a/src/services/hooks/friends/friendService.hook.ts b/src/services/hooks/friends/friendService.hook.ts index 96ae899a..37e259b8 100644 --- a/src/services/hooks/friends/friendService.hook.ts +++ b/src/services/hooks/friends/friendService.hook.ts @@ -19,10 +19,10 @@ interface FriendRequestResponse { export interface FriendRequestError { success: false message: - | 'CANT_REQUEST_YOURSELF' - | 'USER_NOT_FOUND' - | 'FRIEND_REQUEST_ALREADY_SENT' - | 'FRIEND_REQUEST_ALREADY_EXISTS' + | 'CANT_REQUEST_YOURSELF' + | 'USER_NOT_FOUND' + | 'FRIEND_REQUEST_ALREADY_SENT' + | 'FRIEND_REQUEST_ALREADY_EXISTS' } export interface FriendUser { @@ -117,14 +117,14 @@ interface FriendActionResponse { async function sendFriendRequest( params: FriendRequestParams ): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/friends/requests', params) return response.data } async function getFriends(params: GetFriendsParams): Promise { const { status, page, limit } = params - const client = await getMainClient() + const client = getMainClient() const queryParams = new URLSearchParams() queryParams.append('status', status) @@ -138,7 +138,7 @@ async function getFriends(params: GetFriendsParams): Promise { } async function getActivities(): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.get<{ data: ActivitiesResponse }>( `/friends/activities/beta` ) @@ -148,7 +148,7 @@ async function getActivities(): Promise { async function handleFriendRequest( params: FriendActionParams ): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.put( `/friends/requests/${params.friendId}`, { @@ -159,7 +159,7 @@ async function handleFriendRequest( } async function removeFriend(friendId: string): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.delete(`/friends/${friendId}`) return response.data } @@ -231,7 +231,7 @@ export function useGetActivityReactions(id: string, enabled: boolean) { queryKey: ['activity-reactions', id], enabled, queryFn: async (): Promise => { - const client = await getMainClient() + const client = getMainClient() const response = await client.get(`/friends/activities/beta/${id}/reactions`) return response.data.data @@ -245,7 +245,7 @@ export function useGetActivityReactions(id: string, enabled: boolean) { export function useUpsertActivityReaction() { return useMutation({ mutationFn: async (input: { reactionKey: string; activityId: string }) => { - const client = await getMainClient() + const client = getMainClient() await client.put(`/friends/activities/beta/${input.activityId}/reactions`, { reaction: input.reactionKey, diff --git a/src/services/hooks/getDailyMessage.hook.ts b/src/services/hooks/getDailyMessage.hook.ts index fd3a05e3..f7845e3f 100644 --- a/src/services/hooks/getDailyMessage.hook.ts +++ b/src/services/hooks/getDailyMessage.hook.ts @@ -7,16 +7,12 @@ export interface DailyMessageResponse { } async function fetchDailyMessage(): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/extension/day/daily') return data } -export function useGetDailyMessage( - options: { - enabled?: boolean - } = {} -) { +export function useGetDailyMessage(options: { enabled?: boolean } = {}) { return useQuery({ queryKey: ['daily-message'], queryFn: fetchDailyMessage, diff --git a/src/services/hooks/habit/add-habit.hook.ts b/src/services/hooks/habit/add-habit.hook.ts index d2ea631f..e87c8574 100644 --- a/src/services/hooks/habit/add-habit.hook.ts +++ b/src/services/hooks/habit/add-habit.hook.ts @@ -6,7 +6,7 @@ export const useAddHabit = () => { return useMutation({ mutationKey: ['addHabit'], mutationFn: async (input: CreateHabitInput) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/widgets/habits', input) return response.data }, diff --git a/src/services/hooks/habit/archive-habit.hook.ts b/src/services/hooks/habit/archive-habit.hook.ts index b3c11d67..4990cdff 100644 --- a/src/services/hooks/habit/archive-habit.hook.ts +++ b/src/services/hooks/habit/archive-habit.hook.ts @@ -5,7 +5,7 @@ export const useArchiveHabit = () => { return useMutation({ mutationKey: ['archiveHabit'], mutationFn: async (id: string) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.delete(`/widgets/habits/${id}`) return response.data }, diff --git a/src/services/hooks/habit/get-habit-detail.hook.ts b/src/services/hooks/habit/get-habit-detail.hook.ts index 816b490f..d99f0e57 100644 --- a/src/services/hooks/habit/get-habit-detail.hook.ts +++ b/src/services/hooks/habit/get-habit-detail.hook.ts @@ -13,7 +13,7 @@ export const useGetHabitDetail = (habitId: string, enabled: boolean) => { } async function getHabitDetail(habitId: string): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get<{ data: Habit }>(`/widgets/habits/${habitId}`) return data.data } diff --git a/src/services/hooks/habit/get-habits.hook.ts b/src/services/hooks/habit/get-habits.hook.ts index b663f21a..fd0561bb 100644 --- a/src/services/hooks/habit/get-habits.hook.ts +++ b/src/services/hooks/habit/get-habits.hook.ts @@ -26,7 +26,7 @@ export const useGetHabits = (enabled: boolean, archived = false) => { } async function getHabits(archived: boolean): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get<{ data: GetHabitsResponse }>('/widgets/habits', { params: { archived, limit: 50 }, }) diff --git a/src/services/hooks/habit/log-habit-progress.hook.ts b/src/services/hooks/habit/log-habit-progress.hook.ts index 21a0ff3e..72d8e036 100644 --- a/src/services/hooks/habit/log-habit-progress.hook.ts +++ b/src/services/hooks/habit/log-habit-progress.hook.ts @@ -12,7 +12,7 @@ export const useLogHabitProgress = () => { id: string input: LogHabitProgressInput }) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.put(`/widgets/habits/${id}/progress`, input) return response.data }, diff --git a/src/services/hooks/habit/update-habit.hook.ts b/src/services/hooks/habit/update-habit.hook.ts index 7980439a..5e3a00ac 100644 --- a/src/services/hooks/habit/update-habit.hook.ts +++ b/src/services/hooks/habit/update-habit.hook.ts @@ -6,7 +6,7 @@ export const useUpdateHabit = () => { return useMutation({ mutationKey: ['updateHabit'], mutationFn: async ({ id, input }: { id: string; input: UpdateHabitInput }) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.patch(`/widgets/habits/${id}`, input) return response.data }, diff --git a/src/services/hooks/market/getMarketItems.hook.ts b/src/services/hooks/market/getMarketItems.hook.ts index 1f6ba5d6..6232c966 100644 --- a/src/services/hooks/market/getMarketItems.hook.ts +++ b/src/services/hooks/market/getMarketItems.hook.ts @@ -14,7 +14,7 @@ export const useGetMarketItems = (enabled: boolean, params?: MarketQueryParams) export async function getMarketItems( params?: MarketQueryParams ): Promise { - const client = await getMainClient() + const client = getMainClient() const searchParams = new URLSearchParams() if (params?.page) searchParams.append('page', params.page.toString()) diff --git a/src/services/hooks/market/getUserInventory.hook.ts b/src/services/hooks/market/getUserInventory.hook.ts index 8906c058..2c75b63a 100644 --- a/src/services/hooks/market/getUserInventory.hook.ts +++ b/src/services/hooks/market/getUserInventory.hook.ts @@ -13,7 +13,7 @@ export const useGetUserInventory = (enabled: boolean, params?: MarketQueryParams export async function getUserInventory( params?: MarketQueryParams ): Promise { - const client = await getMainClient() + const client = getMainClient() const searchParams = new URLSearchParams() if (params?.page) searchParams.append('page', params.page.toString()) diff --git a/src/services/hooks/market/market-coints.hook.ts b/src/services/hooks/market/market-coints.hook.ts index 5d05d178..12f23341 100644 --- a/src/services/hooks/market/market-coints.hook.ts +++ b/src/services/hooks/market/market-coints.hook.ts @@ -14,7 +14,7 @@ interface GetCoinPackagesParams { const getCoinPackages = async ( params: GetCoinPackagesParams ): Promise => { - const api = await getMainClient() + const api = getMainClient() const response = await api.get('/market/packages/coins', { params: { limit: params.limit || 12, @@ -42,7 +42,7 @@ export const useGetCoinPackages = (params: GetCoinPackagesParams = {}) => { const purchaseCoinPackage = async ( data: PurchaseCoinPackageInput ): Promise => { - const api = await getMainClient() + const api = getMainClient() const response = await api.post('/market/packages/coins/purchase', data) diff --git a/src/services/hooks/market/purchaseMarketItem.hook.ts b/src/services/hooks/market/purchaseMarketItem.hook.ts index a3a8dcbc..e9d3ab5e 100644 --- a/src/services/hooks/market/purchaseMarketItem.hook.ts +++ b/src/services/hooks/market/purchaseMarketItem.hook.ts @@ -27,7 +27,7 @@ export const usePurchaseMarketItem = () => { export async function purchaseMarketItem( params: PurchaseMarketItemParams ): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.post( '/market/purchase', params diff --git a/src/services/hooks/mini-apps/get-mini-app.hook.ts b/src/services/hooks/mini-apps/get-mini-app.hook.ts index 934f4654..180d11e9 100644 --- a/src/services/hooks/mini-apps/get-mini-app.hook.ts +++ b/src/services/hooks/mini-apps/get-mini-app.hook.ts @@ -10,7 +10,7 @@ export const useGetMiniApp = (appId: string) => { return useQuery({ queryKey: ['mini-app', appId], queryFn: async () => { - const api = await getMainClient() + const api = getMainClient() const { data } = await api.get( `/mini-apps/beta/app-id/${appId}` ) diff --git a/src/services/hooks/mini-apps/get-mini-apps.hook.ts b/src/services/hooks/mini-apps/get-mini-apps.hook.ts index 77eb314b..32fcbafa 100644 --- a/src/services/hooks/mini-apps/get-mini-apps.hook.ts +++ b/src/services/hooks/mini-apps/get-mini-apps.hook.ts @@ -11,7 +11,7 @@ export const useGetMiniApps = ({ limit = 20 }: GetMiniAppsParams = {}) => { return useInfiniteQuery({ queryKey: ['mini-apps', limit], queryFn: async ({ pageParam }) => { - const api = await getMainClient() + const api = getMainClient() const response = await api.get('/mini-apps/beta/list', { params: { page: pageParam, limit }, }) diff --git a/src/services/hooks/mini-apps/launch-mini-app.hook.ts b/src/services/hooks/mini-apps/launch-mini-app.hook.ts index 009dadbd..a1d7b890 100644 --- a/src/services/hooks/mini-apps/launch-mini-app.hook.ts +++ b/src/services/hooks/mini-apps/launch-mini-app.hook.ts @@ -5,7 +5,7 @@ import type { MiniAppLaunchResponse } from './mini-apps-interface' export const useLaunchMiniApp = () => { return useMutation({ mutationFn: async ({ appId }) => { - const api = await getMainClient() + const api = getMainClient() const { data } = await api.post( '/mini-apps/beta/launch', { diff --git a/src/services/hooks/moodLog/get-moods.hook.ts b/src/services/hooks/moodLog/get-moods.hook.ts index b11fea9b..2c3b93df 100644 --- a/src/services/hooks/moodLog/get-moods.hook.ts +++ b/src/services/hooks/moodLog/get-moods.hook.ts @@ -24,7 +24,7 @@ export const useGetMoods = (enabled: boolean, start: string, end: string) => { } async function getMoods(start: string, end: string): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get( `/users/@me/moods?start=${start}&end=${end}` ) diff --git a/src/services/hooks/moodLog/upsert-moodLog.hook.ts b/src/services/hooks/moodLog/upsert-moodLog.hook.ts index cdd9166b..5c3c5815 100644 --- a/src/services/hooks/moodLog/upsert-moodLog.hook.ts +++ b/src/services/hooks/moodLog/upsert-moodLog.hook.ts @@ -17,7 +17,7 @@ export function useUpsertMoodLog() { return useMutation({ mutationKey: ['upsertMoodLog'], mutationFn: async (data: MoodLogCreateInput) => { - const api = await getMainClient() + const api = getMainClient() const response = await api.put('/users/@me/moods', data) return response.data }, diff --git a/src/services/hooks/news/getNews.hook.ts b/src/services/hooks/news/getNews.hook.ts index 6ce8776a..41621aa5 100644 --- a/src/services/hooks/news/getNews.hook.ts +++ b/src/services/hooks/news/getNews.hook.ts @@ -36,7 +36,7 @@ export const useGetRss = (url: string, sourceName: string) => { }) } export async function getRss(url: string, sourceName: string): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get( `/news/rss?url=${encodeURIComponent(url)}&sourceName=${encodeURIComponent(sourceName)}` ) @@ -44,7 +44,7 @@ export async function getRss(url: string, sourceName: string): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/news') return data } diff --git a/src/services/hooks/note/delete-note.hook.ts b/src/services/hooks/note/delete-note.hook.ts index 30765a16..4d9f8cd2 100644 --- a/src/services/hooks/note/delete-note.hook.ts +++ b/src/services/hooks/note/delete-note.hook.ts @@ -9,6 +9,6 @@ export const useRemoveNote = () => { } export async function deleteNote(id: string) { - const api = await getMainClient() + const api = getMainClient() await api.delete(`/notes/${id}`) } diff --git a/src/services/hooks/note/get-notes.hook.ts b/src/services/hooks/note/get-notes.hook.ts index 79e9d224..4cf99996 100644 --- a/src/services/hooks/note/get-notes.hook.ts +++ b/src/services/hooks/note/get-notes.hook.ts @@ -3,7 +3,7 @@ import { getMainClient } from '../../api' import type { FetchedNote, GetNotesResponse } from './note.interface' export async function getNotes(): Promise { - const api = await getMainClient() + const api = getMainClient() const response = await api.get('/notes') return response.data.notes } diff --git a/src/services/hooks/note/upsert-note.hook.ts b/src/services/hooks/note/upsert-note.hook.ts index 0a217062..90e5e352 100644 --- a/src/services/hooks/note/upsert-note.hook.ts +++ b/src/services/hooks/note/upsert-note.hook.ts @@ -10,7 +10,7 @@ export const useUpsertNote = () => { } export async function upsertNote(input: NoteCreateInput): Promise { - const api = await getMainClient() + const api = getMainClient() const response = await api.post('/notes', input) diff --git a/src/services/hooks/pomodoro/createSession.hook.ts b/src/services/hooks/pomodoro/createSession.hook.ts index a9ac64b8..db90e387 100644 --- a/src/services/hooks/pomodoro/createSession.hook.ts +++ b/src/services/hooks/pomodoro/createSession.hook.ts @@ -12,7 +12,7 @@ export interface PomodoroSession { export function useCreatePomodoroSession() { return useMutation({ mutationFn: async (data: PomodoroSession) => { - const api = await getMainClient() + const api = getMainClient() await api.post('/pomodoro/session', data) }, }) diff --git a/src/services/hooks/pomodoro/getTopUsers.hook.ts b/src/services/hooks/pomodoro/getTopUsers.hook.ts index be3850e5..9c18c00c 100644 --- a/src/services/hooks/pomodoro/getTopUsers.hook.ts +++ b/src/services/hooks/pomodoro/getTopUsers.hook.ts @@ -26,7 +26,7 @@ export function useGetTopUsers(type: TopUsersType) { return useQuery({ queryKey: ['pomodoro', 'top-users', type], queryFn: async (): Promise => { - const client = await getMainClient() + const client = getMainClient() const res = await client.get('/pomodoro/tops', { params: { type }, }) diff --git a/src/services/hooks/profile/getProfileMeta.hook.ts b/src/services/hooks/profile/getProfileMeta.hook.ts index 229e1dd9..3023b1de 100644 --- a/src/services/hooks/profile/getProfileMeta.hook.ts +++ b/src/services/hooks/profile/getProfileMeta.hook.ts @@ -14,7 +14,7 @@ export interface ProfileMetaItem { async function fetchProfileMeta( type: 'OCCUPATION' | 'INTEREST' ): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.get(`/profile-meta?type=${type}`) return response.data } diff --git a/src/services/hooks/search/getSuggestSearch.hook.ts b/src/services/hooks/search/getSuggestSearch.hook.ts index 55420eb9..97e46852 100644 --- a/src/services/hooks/search/getSuggestSearch.hook.ts +++ b/src/services/hooks/search/getSuggestSearch.hook.ts @@ -10,10 +10,13 @@ interface SuggestSearchResponse { } async function fetchSuggestSearch(term: string): Promise { - const client = await getMainClient() - const response = await client.get('/searchbox/suggest-search', { - params: { term }, - }) + const client = getMainClient() + const response = await client.get( + '/searchbox/suggest-search', + { + params: { term }, + } + ) return (response.data?.data?.list ?? []).slice(0, MAX_SUGGESTIONS) } diff --git a/src/services/hooks/timezone/getTimezones.hook.ts b/src/services/hooks/timezone/getTimezones.hook.ts index cffdf96a..608c9735 100644 --- a/src/services/hooks/timezone/getTimezones.hook.ts +++ b/src/services/hooks/timezone/getTimezones.hook.ts @@ -9,7 +9,7 @@ export interface FetchedTimezone { export async function getTimezones(): Promise { try { - const api = await getMainClient() + const api = getMainClient() const response = await api.get('/date/timezones') return response.data } catch { diff --git a/src/services/hooks/todo/add-todo.hook.ts b/src/services/hooks/todo/add-todo.hook.ts index 9b7109c1..be8b70ab 100644 --- a/src/services/hooks/todo/add-todo.hook.ts +++ b/src/services/hooks/todo/add-todo.hook.ts @@ -31,7 +31,7 @@ export const useAddTodoState = () => { } export async function AddTodoApi(input: TodoCreationPayload) { - const client = await getMainClient() + const client = getMainClient() const response = await client.post(`/todos`, input) diff --git a/src/services/hooks/todo/get-tags.hook.ts b/src/services/hooks/todo/get-tags.hook.ts index 1a10c5f3..2b49cccb 100644 --- a/src/services/hooks/todo/get-tags.hook.ts +++ b/src/services/hooks/todo/get-tags.hook.ts @@ -10,7 +10,7 @@ export const useGetTags = (enabled: boolean) => { }) } export async function getTags(): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/todos/@me/tags') return data } diff --git a/src/services/hooks/todo/get-todos.hook.ts b/src/services/hooks/todo/get-todos.hook.ts index a210ff7b..310f71a1 100644 --- a/src/services/hooks/todo/get-todos.hook.ts +++ b/src/services/hooks/todo/get-todos.hook.ts @@ -32,7 +32,7 @@ export const useGetTodos = (enabled: boolean, params?: Omit { - const client = await getMainClient() + const client = getMainClient() const queryParams = new URLSearchParams() if (params?.page) queryParams.append('page', params.page.toString()) diff --git a/src/services/hooks/todo/remove-todo.hook.ts b/src/services/hooks/todo/remove-todo.hook.ts index 40bf856f..30f646a4 100644 --- a/src/services/hooks/todo/remove-todo.hook.ts +++ b/src/services/hooks/todo/remove-todo.hook.ts @@ -9,6 +9,6 @@ export const useRemoveTodo = (id: string) => { } export async function RemoveTodoApi(todoId: string) { - const client = await getMainClient() + const client = getMainClient() await client.delete(`/todos/${todoId}`) } diff --git a/src/services/hooks/todo/reorder-todo.hook.ts b/src/services/hooks/todo/reorder-todo.hook.ts index 6dc7322a..872aab18 100644 --- a/src/services/hooks/todo/reorder-todo.hook.ts +++ b/src/services/hooks/todo/reorder-todo.hook.ts @@ -16,7 +16,7 @@ export const useReorderTodos = () => { } export async function ReorderTodosApi(todos: TodoReorderPayload[]) { - const client = await getMainClient() + const client = getMainClient() const response = await client.put('/todos/order', { todos }) diff --git a/src/services/hooks/todo/update-todo.hook.ts b/src/services/hooks/todo/update-todo.hook.ts index a0caf4ea..54d1ec24 100644 --- a/src/services/hooks/todo/update-todo.hook.ts +++ b/src/services/hooks/todo/update-todo.hook.ts @@ -22,7 +22,7 @@ export const useUpdateTodo = (todoId: string | null) => { } export async function UpdateTodoApi(id: string, input: TodoUpdatePayload) { - const client = await getMainClient() + const client = getMainClient() const response = await client.patch<{ data: { diff --git a/src/services/hooks/translate/translateService.ts b/src/services/hooks/translate/translateService.ts index 40ee8be0..70cb77a8 100644 --- a/src/services/hooks/translate/translateService.ts +++ b/src/services/hooks/translate/translateService.ts @@ -9,13 +9,13 @@ import type { export async function translateText( request: TranslateRequestInput ): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.post('/translate', request) return response.data } export async function getAvailableLanguages(): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.get( '/translate/available-languages' ) diff --git a/src/services/hooks/trends/getTrends.ts b/src/services/hooks/trends/getTrends.ts index 21b816ac..c4d86369 100644 --- a/src/services/hooks/trends/getTrends.ts +++ b/src/services/hooks/trends/getTrends.ts @@ -37,7 +37,7 @@ export interface SearchBoxResponse { } async function fetchSearchbox(region = 'IR', limit = 10): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.get('/searchbox', { params: { diff --git a/src/services/hooks/user/referralsService.hook.ts b/src/services/hooks/user/referralsService.hook.ts index bb65f8da..eb157294 100644 --- a/src/services/hooks/user/referralsService.hook.ts +++ b/src/services/hooks/user/referralsService.hook.ts @@ -38,7 +38,7 @@ export interface GetReferralsParams { async function getReferrals(params: GetReferralsParams = {}): Promise { const { page, limit } = params - const client = await getMainClient() + const client = getMainClient() const queryParams = new URLSearchParams() if (page !== undefined) queryParams.append('page', page.toString()) @@ -60,7 +60,7 @@ export function useGetReferrals(params: GetReferralsParams = {}) { } async function getOrCreateReferralCode(): Promise<{ referralCode: string }> { - const client = await getMainClient() + const client = getMainClient() const response = await client.get<{ referralCode: string }>('/users/@me/rewards/code') return response.data } diff --git a/src/services/hooks/user/userService.hook.ts b/src/services/hooks/user/userService.hook.ts index a660fc20..7c7e0b21 100644 --- a/src/services/hooks/user/userService.hook.ts +++ b/src/services/hooks/user/userService.hook.ts @@ -61,7 +61,7 @@ export interface UserProfile extends FetchedProfile { } export async function fetchUserProfile(): Promise { - const client = await getMainClient() + const client = getMainClient() try { const response = await client.get('/extension/@me') await setToStorage('profile', { ...response.data, inCache: true }) @@ -101,7 +101,7 @@ export function useGetUserMoodStatus(enabled: boolean) { return useQuery({ queryKey: ['userMoodStatus'], queryFn: async () => { - const client = await getMainClient() + const client = getMainClient() const response = await client.get('/users/@me/moods/status') @@ -124,7 +124,7 @@ interface UpdateActivityResponse { async function updateActivity( body: UpdateActivityParams ): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.put( '/extension/@me/activity', body @@ -144,7 +144,7 @@ export function useUpdateActivity() { } export async function sendVerificationEmail(): Promise { - const api = await getMainClient() + const api = getMainClient() const response = await api.post('/auth/email/resend-verify') return response.data } @@ -157,7 +157,7 @@ export function useSendVerificationEmail() { } async function setCityToServer(cityId: string): Promise { - const client = await getMainClient() + const client = getMainClient() await client.put('/users/@me/city', { cityId }) } @@ -183,7 +183,7 @@ export function useSetCity() { export function useChangePhoneRequest() { return useMutation({ mutationFn: async (phone: string) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.put( '/users/@me/change-phone', { phone } @@ -196,7 +196,7 @@ export function useChangePhoneRequest() { export function useChangePhoneVerify() { return useMutation({ mutationFn: async (body: { phone: string; code: string }) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.put( '/users/@me/change-phone/verify', body @@ -209,7 +209,7 @@ export function useChangePhoneVerify() { export function useChangeEmailRequest() { return useMutation({ mutationFn: async (email: string) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.put( '/users/@me/change-email', { email } @@ -222,7 +222,7 @@ export function useChangeEmailRequest() { export function useChangeEmailVerify() { return useMutation({ mutationFn: async (body: { email: string; code: string }) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.put( '/users/@me/change-email/verify', body @@ -237,7 +237,7 @@ export function useSetActivity() { return useMutation({ mutationFn: async (body: { content: string; time: number }) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.put('/users/@me/activities/beta', body) return response.data }, @@ -251,7 +251,7 @@ export function useRemoveActivity() { return useMutation({ mutationFn: async (body: { id: string }) => { - const client = await getMainClient() + const client = getMainClient() const response = await client.delete(`/users/@me/activities/${body.id}`) return response.data }, diff --git a/src/services/hooks/wallpapers/getWallpaperCategories.hook.ts b/src/services/hooks/wallpapers/getWallpaperCategories.hook.ts index 6e095b10..aaccf66f 100644 --- a/src/services/hooks/wallpapers/getWallpaperCategories.hook.ts +++ b/src/services/hooks/wallpapers/getWallpaperCategories.hook.ts @@ -39,7 +39,7 @@ export const useGetWallpaperCategoriesPaginated = ( return useQuery({ queryKey: ['getWallpaperCategoriesPaginated', queryParams.toString()], queryFn: async () => { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get(endpoint) return data }, @@ -50,7 +50,7 @@ export const useGetWallpaperCategoriesPaginated = ( } async function getWallpaperCategories(): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/wallpapers/categories') return data } @@ -83,7 +83,7 @@ export const useGetWallpapers = (q: GetWallpaperQuery, enabled: boolean) => { return useQuery({ queryKey: ['getWallpapers', queryParams.toString()], queryFn: async () => { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get(endpoint) return data }, @@ -126,7 +126,7 @@ async function getWallpapersByCategoryId( queryParams.append('market', String(params.market)) } - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/wallpapers', { params: queryParams, }) @@ -135,7 +135,7 @@ async function getWallpapersByCategoryId( export async function getRandomWallpaper(): Promise { try { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get('/wallpapers?random=true') return data.wallpapers[0] } catch { diff --git a/src/services/hooks/wallpapers/getWallpaperPreviewUrl.hook.ts b/src/services/hooks/wallpapers/getWallpaperPreviewUrl.hook.ts index eab4a71d..5bbecd0c 100644 --- a/src/services/hooks/wallpapers/getWallpaperPreviewUrl.hook.ts +++ b/src/services/hooks/wallpapers/getWallpaperPreviewUrl.hook.ts @@ -5,7 +5,7 @@ interface WallpaperPreviewResponse { } export async function fetchWallpaperPreviewUrl(wallpaperId: string): Promise { - const client = await getMainClient() + const client = getMainClient() const { data } = await client.get<{ data: WallpaperPreviewResponse }>( `/wallpapers/${wallpaperId}/preview` ) diff --git a/src/services/hooks/weather/getForecastWeatherByLatLon.ts b/src/services/hooks/weather/getForecastWeatherByLatLon.ts index c52670ba..7677c665 100644 --- a/src/services/hooks/weather/getForecastWeatherByLatLon.ts +++ b/src/services/hooks/weather/getForecastWeatherByLatLon.ts @@ -8,7 +8,7 @@ interface Options { async function fetchForecastWeatherByLatLon( options: Options ): Promise { - const client = await getMainClient() + const client = getMainClient() const response = await client.get('/weather/forecast', { params: { diff --git a/src/services/hooks/weather/getRelatedCities.ts b/src/services/hooks/weather/getRelatedCities.ts index 9497882a..22f1ba9e 100644 --- a/src/services/hooks/weather/getRelatedCities.ts +++ b/src/services/hooks/weather/getRelatedCities.ts @@ -4,7 +4,7 @@ import type { FetchedCity } from '../../../layouts/widgets/weather/weather.inter async function fetchRelatedCities(city: string): Promise { if (city.length > 1) { - const client = await getMainClient() + const client = getMainClient() const response = await client.get(`/weather/cities?city=${city}`) return response.data diff --git a/src/services/hooks/weather/getWeatherByLatLon.ts b/src/services/hooks/weather/getWeatherByLatLon.ts index 2ed5c66d..685b8386 100644 --- a/src/services/hooks/weather/getWeatherByLatLon.ts +++ b/src/services/hooks/weather/getWeatherByLatLon.ts @@ -4,7 +4,7 @@ import { getMainClient } from '@/services/api' import type { FetchedWeather } from '../../../layouts/widgets/weather/weather.interface' async function fetchWeatherByLatLon(addForecast: boolean): Promise { - const client = await getMainClient() + const client = getMainClient() const params = new URLSearchParams() if (addForecast) { params.append('addForecast', 'true')