Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Prune legacy data from Cliqz browser (#371)
- Loading branch information
Showing
with
16 additions
and
1 deletion.
-
+16
−1
cliqz.js
|
|
@@ -2,12 +2,27 @@ import 'react-native/Libraries/Core/InitializeCore'; |
|
|
import './setup'; |
|
|
import 'process-nextick-args'; |
|
|
import React from 'react'; |
|
|
import { AppRegistry, StyleSheet, View } from 'react-native'; |
|
|
import { AppRegistry, StyleSheet, View, AsyncStorage } from 'react-native'; |
|
|
import { startup, components } from 'browser-core-cliqz-ios'; |
|
|
|
|
|
async function cleanUpStorage() { |
|
|
const migrateKey = '@migrated'; |
|
|
const migrateVersion = '1'; |
|
|
const migrated = await AsyncStorage.getItem(migrateKey); |
|
|
if (migrated !== migrateVersion) { |
|
|
console.log('Migrate legacy storage'); |
|
|
const keys = await AsyncStorage.getAllKeys(); |
|
|
// prune legacy fs and anti-tracking storage namespaces |
|
|
const pruneKeys = keys.filter(k => k.startsWith('@fs:') || k.startsWith('@cliqzstorage')); |
|
|
await AsyncStorage.multiRemove(pruneKeys); |
|
|
await AsyncStorage.setItem(migrateKey, migrateVersion); |
|
|
} |
|
|
} |
|
|
|
|
|
// set app global for debugging |
|
|
const appStart = startup.then((app) => { |
|
|
global.app = app; |
|
|
cleanUpStorage(); |
|
|
}); |
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|