mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Fix public domain and API domain differ
This commit is contained in:
@ -18,9 +18,10 @@ export type AccountV0 = {
|
||||
'auth.clientId': string
|
||||
'auth.clientSecret': string
|
||||
'auth.token': string
|
||||
'auth.domain': string
|
||||
'auth.domain': string // used for API
|
||||
'auth.account.id': string
|
||||
'auth.account.acct': string
|
||||
'auth.account.domain': string // used for username
|
||||
'auth.account.avatar_static': string
|
||||
version: string
|
||||
// number
|
||||
|
@ -24,10 +24,16 @@ export const getGlobalStorage = {
|
||||
storage.global.getBoolean(key) as NonNullable<StorageGlobal[T]> extends boolean
|
||||
? StorageGlobal[T]
|
||||
: never,
|
||||
object: <T extends keyof StorageGlobal>(key: T) =>
|
||||
JSON.parse(storage.global.getString(key) || '') as NonNullable<StorageGlobal[T]> extends object
|
||||
? StorageGlobal[T]
|
||||
: never
|
||||
object: <T extends keyof StorageGlobal>(key: T) => {
|
||||
const value = storage.global.getString(key)
|
||||
if (value?.length) {
|
||||
return JSON.parse(value) as NonNullable<StorageGlobal[T]> extends object
|
||||
? StorageGlobal[T]
|
||||
: never
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
export const useGlobalStorage = {
|
||||
string: <T extends keyof StorageGlobal>(key: T) =>
|
||||
@ -84,7 +90,7 @@ export const getAccountStorage = {
|
||||
: never,
|
||||
object: <T extends keyof StorageAccount>(key: T) => {
|
||||
const value = storage.account?.getString(key)
|
||||
if (value) {
|
||||
if (value?.length) {
|
||||
return JSON.parse(value) as NonNullable<StorageAccount[T]> extends object
|
||||
? StorageAccount[T]
|
||||
: never
|
||||
@ -166,8 +172,9 @@ export const getAccountDetails = <T extends Array<keyof StorageAccount>>(
|
||||
case 'auth.clientSecret':
|
||||
case 'auth.token':
|
||||
case 'auth.domain':
|
||||
case 'auth.account.id':
|
||||
case 'auth.account.acct':
|
||||
case 'auth.account.domain':
|
||||
case 'auth.account.id':
|
||||
case 'auth.account.avatar_static':
|
||||
// @ts-ignore
|
||||
result[key] = temp.getString(key)
|
||||
@ -180,9 +187,12 @@ export const getAccountDetails = <T extends Array<keyof StorageAccount>>(
|
||||
case 'drafts':
|
||||
case 'emojis_frequent':
|
||||
const value = temp.getString(key)
|
||||
if (value) {
|
||||
if (value?.length) {
|
||||
// @ts-ignore
|
||||
result[key] = JSON.parse(value)
|
||||
} else {
|
||||
// @ts-ignore
|
||||
result[key] = undefined
|
||||
}
|
||||
break
|
||||
}
|
||||
|
@ -67,16 +67,17 @@ export async function migrateFromAsyncStorage(): Promise<void> {
|
||||
const accounts: string[] = []
|
||||
|
||||
for (const instance of JSON.parse(storeInstances.instances)) {
|
||||
const account = `${instance.uri}/${instance.account.id}`
|
||||
const account = `${instance.url}/${instance.account.id}`
|
||||
|
||||
const temp = new MMKV({ id: account })
|
||||
temp.set('auth.clientId', instance.appData.clientId)
|
||||
temp.set('auth.clientSecret', instance.appData.clientSecret)
|
||||
temp.set('auth.token', instance.token)
|
||||
temp.set('auth.domain', instance.uri)
|
||||
temp.set('auth.domain', instance.url)
|
||||
|
||||
temp.set('auth.account.id', instance.account.id)
|
||||
temp.set('auth.account.acct', instance.account.acct)
|
||||
temp.set('auth.account.domain', instance.uri)
|
||||
temp.set('auth.account.id', instance.account.id)
|
||||
temp.set('auth.account.avatar_static', instance.account.avatarStatic)
|
||||
|
||||
if (instance.account.preferences) {
|
||||
|
Reference in New Issue
Block a user