This commit is contained in:
xmflsct 2022-12-19 21:20:14 +01:00
parent bace3b85de
commit 4bd11e2246
1 changed files with 14 additions and 24 deletions

View File

@ -1,33 +1,26 @@
import apiGeneral from '@api/general' import apiTooot from '@api/tooot'
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit' import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'
import { RootState } from '@root/store' import { RootState } from '@root/store'
import { isDevelopment } from '@utils/checkEnvironment' import { isDevelopment } from '@utils/checkEnvironment'
import Constants from 'expo-constants' import Constants from 'expo-constants'
import * as Notifications from 'expo-notifications' import * as Notifications from 'expo-notifications'
export const retrieveExpoToken = createAsyncThunk( export const retrieveExpoToken = createAsyncThunk('app/expoToken', async (): Promise<string> => {
'app/expoToken', if (isDevelopment) {
async (): Promise<string> => { return 'ExponentPushToken[DEVELOPMENT_1]'
if (isDevelopment) {
return 'ExponentPushToken[DEVELOPMENT_1]'
}
const res = await Notifications.getExpoPushTokenAsync({
experienceId: '@xmflsct/tooot',
applicationId: 'com.xmflsct.app.tooot'
})
return res.data
} }
)
const res = await Notifications.getExpoPushTokenAsync({
experienceId: '@xmflsct/tooot',
applicationId: 'com.xmflsct.app.tooot'
})
return res.data
})
export const retrieveVersionLatest = createAsyncThunk( export const retrieveVersionLatest = createAsyncThunk(
'app/versionUpdate', 'app/versionUpdate',
async (): Promise<string> => { async (): Promise<string> => {
const res = await apiGeneral<{ latest: string }>({ const res = await apiTooot<{ latest: string }>({ method: 'get', url: 'version.json' })
method: 'get',
domain: 'tooot.app',
url: 'version.json'
})
return res.body.latest return res.body.latest
} }
) )
@ -55,11 +48,8 @@ const appSlice = createSlice({
}) })
.addCase(retrieveVersionLatest.fulfilled, (state, action) => { .addCase(retrieveVersionLatest.fulfilled, (state, action) => {
if (action.payload && Constants.expoConfig?.version) { if (action.payload && Constants.expoConfig?.version) {
if ( state.versionUpdate =
parseFloat(action.payload) > parseFloat(Constants.expoConfig?.version) parseFloat(action.payload) > parseFloat(Constants.expoConfig.version)
) {
state.versionUpdate = true
}
} }
}) })
} }