Try to fix Android storage issue

This commit is contained in:
Zhiyuan Zheng 2022-05-19 00:46:25 +02:00
parent 0479e2fc9f
commit 67b15f75f5
4 changed files with 23 additions and 10 deletions

View File

@ -4,7 +4,7 @@
"native": "220508", "native": "220508",
"major": 4, "major": 4,
"minor": 0, "minor": 0,
"patch": 2, "patch": 3,
"expo": "45.0.0" "expo": "45.0.0"
}, },
"description": "tooot app for Mastodon", "description": "tooot app for Mastodon",

View File

@ -378,10 +378,7 @@ const ScreenCompose: React.FC<RootStackScreenProps<'Screen-Compose'>> = ({
) )
} else { } else {
Sentry.Native.captureMessage('Compose posting', { Sentry.Native.captureMessage('Compose posting', {
contexts: { contexts: { errorObject: error }
errorObject: error,
errorString: error.toString()
}
}) })
haptics('Error') haptics('Error')
composeDispatch({ type: 'posting', payload: false }) composeDispatch({ type: 'posting', payload: false })

View File

@ -1,4 +1,4 @@
import apiInstance from '@api/instance' import apiInstance, { InstanceResponse } from '@api/instance'
import { ComposeState } from '@screens/Compose/utils/types' import { ComposeState } from '@screens/Compose/utils/types'
import { RootStackParamList } from '@utils/navigation/navigators' import { RootStackParamList } from '@utils/navigation/navigators'
import * as Crypto from 'expo-crypto' import * as Crypto from 'expo-crypto'
@ -6,7 +6,7 @@ import * as Crypto from 'expo-crypto'
const composePost = async ( const composePost = async (
params: RootStackParamList['Screen-Compose'], params: RootStackParamList['Screen-Compose'],
composeState: ComposeState composeState: ComposeState
) => { ): Promise<InstanceResponse<Mastodon.Status>> => {
const formData = new FormData() const formData = new FormData()
if (composeState.replyToStatus) { if (composeState.replyToStatus) {

View File

@ -8,8 +8,19 @@ import contextsSlice, { ContextsState } from '@utils/slices/contextsSlice'
import instancesSlice, { InstancesState } from '@utils/slices/instancesSlice' import instancesSlice, { InstancesState } from '@utils/slices/instancesSlice'
import settingsSlice, { SettingsState } from '@utils/slices/settingsSlice' import settingsSlice, { SettingsState } from '@utils/slices/settingsSlice'
import versionSlice from '@utils/slices/versionSlice' import versionSlice from '@utils/slices/versionSlice'
import { Platform } from 'react-native'
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
import { createMigrate, persistReducer, persistStore } from 'redux-persist' import {
createMigrate,
FLUSH,
PAUSE,
PERSIST,
persistReducer,
persistStore,
PURGE,
REGISTER,
REHYDRATE
} from 'redux-persist'
const secureStorage = createSecureStore() const secureStorage = createSecureStore()
@ -27,7 +38,7 @@ const contextsPersistConfig = {
const instancesPersistConfig = { const instancesPersistConfig = {
key: 'instances', key: 'instances',
prefix, prefix,
storage: secureStorage, storage: Platform.OS === 'ios' ? secureStorage : AsyncStorage,
version: 9, version: 9,
// @ts-ignore // @ts-ignore
migrate: createMigrate(instancesMigration) migrate: createMigrate(instancesMigration)
@ -61,8 +72,13 @@ const store = configureStore({
middleware: getDefaultMiddleware => middleware: getDefaultMiddleware =>
getDefaultMiddleware({ getDefaultMiddleware({
serializableCheck: { serializableCheck: {
ignoredActions: ['persist/PERSIST'] ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
} }
}).concat(store => next => action => {
console.log('dispatching', action)
let result = next(action)
console.log('next state', store.getState())
return result
}) })
}) })