Skip to content

Commit e44940c

Browse files
committed
feat: clear MMKV on fresh install
1 parent fc5e020 commit e44940c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/components/Nav/App/App.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
EXISTING_USER,
3535
LAST_APP_VERSION,
3636
} from '../../../constants/storage';
37-
import { getVersion } from 'react-native-device-info';
37+
import { getVersion, getFirstInstallTime, getLastUpdateTime } from 'react-native-device-info';
3838
import { Authentication } from '../../../core/';
3939
import Device from '../../../util/device';
4040
import SDKConnect from '../../../core/SDKConnect/SDKConnect';
@@ -922,6 +922,15 @@ const App: React.FC = () => {
922922

923923
useEffect(() => {
924924
async function startApp() {
925+
const firstInstallTime = await getFirstInstallTime();
926+
const lastUpdateTime = await getLastUpdateTime();
927+
const isFreshInstall = firstInstallTime === lastUpdateTime;
928+
929+
if (isFreshInstall) {
930+
// Clear all MMKV storage on fresh install to avoid leftovers of EXISTING_USER in case of phone migration
931+
await StorageWrapper.clearAll();
932+
}
933+
925934
const existingUser = await StorageWrapper.getItem(EXISTING_USER);
926935
if (!existingUser) {
927936
// List of chainIds to add (as hex strings)

0 commit comments

Comments
 (0)