mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-27 00:59:28 +01:00
add reset button for db
This commit is contained in:
parent
ef69e9d517
commit
f9f016b932
@ -5,11 +5,23 @@ import React from 'react';
|
||||
import { Button, Text, View } from 'react-native';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { appSettingsAtom } from '../state/settings';
|
||||
import { getAllKeys, multiRemove } from '../storage/asyncstorage';
|
||||
import text from '../styles/text';
|
||||
|
||||
const TestControls = () => {
|
||||
const navigation = useNavigation();
|
||||
|
||||
const removeAllKeys = async () => {
|
||||
const allKeys = await getAllKeys();
|
||||
await multiRemove(allKeys);
|
||||
}
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Button
|
||||
title='Remove all keys'
|
||||
onPress={removeAllKeys}
|
||||
/>
|
||||
<Button
|
||||
title='Now Playing'
|
||||
onPress={() => navigation.navigate('Now Playing')}
|
||||
@ -52,8 +64,8 @@ const ServerSettingsView = () => {
|
||||
/>
|
||||
{appSettings.servers.map(s => (
|
||||
<View key={s.id}>
|
||||
<Text>{s.address}</Text>
|
||||
<Text>{s.username}</Text>
|
||||
<Text style={text.paragraph}>{s.address}</Text>
|
||||
<Text style={text.paragraph}>{s.username}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
|
||||
@ -35,3 +35,20 @@ export async function multiSet(items: string[][]): Promise<void> {
|
||||
console.error(`multiSet error`, e);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAllKeys(): Promise<string[]> {
|
||||
try {
|
||||
return await AsyncStorage.getAllKeys();
|
||||
} catch (e) {
|
||||
console.error(`getAllKeys error`, e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function multiRemove(keys: string[]): Promise<void> {
|
||||
try {
|
||||
await AsyncStorage.multiRemove(keys);
|
||||
} catch (e) {
|
||||
console.error(`multiRemove error`, e);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user