From 4bd11e22461fbfbaf5da3820f05d4ae8b3ab2692 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Mon, 19 Dec 2022 21:20:14 +0100 Subject: [PATCH] Fix #581 --- src/utils/slices/appSlice.ts | 38 +++++++++++++----------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/utils/slices/appSlice.ts b/src/utils/slices/appSlice.ts index 37c9f5db..d65c0d4b 100644 --- a/src/utils/slices/appSlice.ts +++ b/src/utils/slices/appSlice.ts @@ -1,33 +1,26 @@ -import apiGeneral from '@api/general' +import apiTooot from '@api/tooot' import { createAsyncThunk, createSlice } from '@reduxjs/toolkit' import { RootState } from '@root/store' import { isDevelopment } from '@utils/checkEnvironment' import Constants from 'expo-constants' import * as Notifications from 'expo-notifications' -export const retrieveExpoToken = createAsyncThunk( - 'app/expoToken', - async (): Promise => { - if (isDevelopment) { - return 'ExponentPushToken[DEVELOPMENT_1]' - } - - const res = await Notifications.getExpoPushTokenAsync({ - experienceId: '@xmflsct/tooot', - applicationId: 'com.xmflsct.app.tooot' - }) - return res.data +export const retrieveExpoToken = createAsyncThunk('app/expoToken', async (): Promise => { + if (isDevelopment) { + return 'ExponentPushToken[DEVELOPMENT_1]' } -) + + const res = await Notifications.getExpoPushTokenAsync({ + experienceId: '@xmflsct/tooot', + applicationId: 'com.xmflsct.app.tooot' + }) + return res.data +}) export const retrieveVersionLatest = createAsyncThunk( 'app/versionUpdate', async (): Promise => { - const res = await apiGeneral<{ latest: string }>({ - method: 'get', - domain: 'tooot.app', - url: 'version.json' - }) + const res = await apiTooot<{ latest: string }>({ method: 'get', url: 'version.json' }) return res.body.latest } ) @@ -55,11 +48,8 @@ const appSlice = createSlice({ }) .addCase(retrieveVersionLatest.fulfilled, (state, action) => { if (action.payload && Constants.expoConfig?.version) { - if ( - parseFloat(action.payload) > parseFloat(Constants.expoConfig?.version) - ) { - state.versionUpdate = true - } + state.versionUpdate = + parseFloat(action.payload) > parseFloat(Constants.expoConfig.version) } }) }