mirror of https://github.com/tooot-app/app
Fix #581
This commit is contained in:
parent
bace3b85de
commit
4bd11e2246
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue