import { useNavigation } from '@react-navigation/core'
import { useAtom } from 'jotai'
import md5 from 'md5'
import React from 'react'
import { Button, StyleSheet, Text, View } from 'react-native'
import { v4 as uuidv4 } from 'uuid'
import { appSettingsAtom } from '@app/state/settings'
import { getAllKeys, multiRemove } from '@app/storage/asyncstorage'
const TestControls = () => {
const navigation = useNavigation()
const removeAllKeys = async () => {
const allKeys = await getAllKeys()
await multiRemove(allKeys)
}
return (
)
}
const ServerSettingsView = () => {
const [appSettings, setAppSettings] = useAtom(appSettingsAtom)
const bootstrapServer = () => {
if (appSettings.servers.length !== 0) {
return
}
const id = uuidv4()
const salt = uuidv4()
const address = 'http://demo.subsonic.org'
setAppSettings({
...appSettings,
servers: [
...appSettings.servers,
{
id,
salt,
address,
username: 'guest',
token: md5('guest' + salt),
},
],
activeServer: id,
})
}
return (
{appSettings.servers.map(s => (
{s.address}
{s.username}
))}
)
}
const SettingsView = () => (
Loading...}>
)
const styles = StyleSheet.create({
text: {
color: 'white',
},
})
export default SettingsView