export function migrateToIssuesFilterSearch()

in src/actions/app-actions.ts [910:939]


export function migrateToIssuesFilterSearch(): ReduxAction {
  return async (dispatch: ReduxThunkDispatch) => {
    const storageState: StorageState = storage.getStorageState();
    let shouldMigrate;
    try {
      const curAppVer = (storageState.currentAppVersion || '')?.split('.');
      const nextAppVer = packageJson.version.split('.');
      const curr = curAppVer.map(it => parseInt(it, 10));
      const next = nextAppVer.map(it => parseInt(it, 10));
      const isNextVerToMigrate: boolean = next[0] === 2023 && next[1] === 3 && next[2] === 1;
      shouldMigrate = (
        !storageState.currentAppVersion ||
        curr[0] < next[0] && isNextVerToMigrate ||
        curr[0] === next[0] && isNextVerToMigrate && curr[1] < 3
      );
    } catch (e) {
      shouldMigrate = false;
    }
    if (shouldMigrate) {
      const doUpdate = (it: StorageState): StorageState => ({...it, query: ''}) as StorageState;
      await storage.flushStorage(doUpdate(storageState));
      const otherAccounts: StorageState[] = await storage.getOtherAccounts();
      if (otherAccounts.length > 0) {
        const updatedOtherAccounts: StorageState[] = otherAccounts.map(doUpdate);
        await storage.storeAccounts(updatedOtherAccounts);
        dispatch(receiveOtherAccounts(updatedOtherAccounts));
      }
    }
  };
}