mirror of https://github.com/tooot-app/app
Fix public domain and API domain differ
This commit is contained in:
parent
53ea661d9a
commit
c6aff79055
|
@ -306,7 +306,7 @@ PODS:
|
|||
- React-Core
|
||||
- react-native-language-detection (0.2.2):
|
||||
- React
|
||||
- react-native-menu (0.7.2):
|
||||
- react-native-menu (0.7.3):
|
||||
- React
|
||||
- react-native-mmkv (2.5.1):
|
||||
- MMKV (>= 1.2.13)
|
||||
|
@ -748,7 +748,7 @@ SPEC CHECKSUMS:
|
|||
react-native-image-picker: 60f4246eb5bb7187fc15638a8c1f13abd3820695
|
||||
react-native-ios-context-menu: b170594b4448c0cd10c79e13432216bac99de1ac
|
||||
react-native-language-detection: f414937fa715108ab50a6269a3de0bcb95e4ceb0
|
||||
react-native-menu: 8e172cfcf0e42e92f028e7781eddf84d430cae24
|
||||
react-native-menu: 9d7d6f819cc7fa14a15cf86888c53f3240d86f1b
|
||||
react-native-mmkv: 69b9c003f10afdd01addf7c6ee784ce42ee2eff3
|
||||
react-native-netinfo: 2517ad504b3d303e90d7a431b0fcaef76d207983
|
||||
react-native-pager-view: 54bed894cecebe28cede54c01038d9d1e122de43
|
||||
|
|
|
@ -86,5 +86,7 @@
|
|||
<string>Automatic</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -15,7 +15,7 @@ interface Props {
|
|||
const AccountButton: React.FC<Props> = ({ account, selected = false, additionalActions }) => {
|
||||
const navigation = useNavigation()
|
||||
const accountDetails = getAccountDetails(
|
||||
['auth.account.acct', 'auth.domain', 'auth.account.id'],
|
||||
['auth.domain', 'auth.account.acct', 'auth.account.domain', 'auth.account.id'],
|
||||
account
|
||||
)
|
||||
if (!accountDetails) return null
|
||||
|
@ -28,7 +28,7 @@ const AccountButton: React.FC<Props> = ({ account, selected = false, additionalA
|
|||
marginBottom: StyleConstants.Spacing.M,
|
||||
marginRight: StyleConstants.Spacing.M
|
||||
}}
|
||||
content={`@${accountDetails['auth.account.acct']}@${accountDetails['auth.domain']}${
|
||||
content={`@${accountDetails['auth.account.acct']}@${accountDetails['auth.account.domain']}${
|
||||
selected ? ' ✓' : ''
|
||||
}`}
|
||||
onPress={() => {
|
||||
|
|
|
@ -123,6 +123,8 @@ const ComponentInstance: React.FC<Props> = ({
|
|||
'auth.domain': domain,
|
||||
'auth.account.id': id,
|
||||
'auth.account.acct': acct,
|
||||
// @ts-ignore
|
||||
'auth.account.domain': instanceQuery.data?.domain || instanceQuery.data?.uri,
|
||||
'auth.account.avatar_static': avatar_static,
|
||||
version: instanceQuery.data?.version || '0',
|
||||
preferences: undefined,
|
||||
|
|
|
@ -23,7 +23,7 @@ const ComposePostingAs = () => {
|
|||
<CustomText fontStyle='S' style={{ color: colors.secondary }}>
|
||||
{t('content.root.header.postingAs', {
|
||||
acct: getAccountStorage.string('auth.account.acct'),
|
||||
domain: getAccountStorage.string('auth.domain')
|
||||
domain: getAccountStorage.string('auth.account.domain')
|
||||
})}
|
||||
</CustomText>
|
||||
</View>
|
||||
|
|
|
@ -29,8 +29,9 @@ const TabMePush: React.FC = () => {
|
|||
const [expoToken] = useGlobalStorage.string('app.expo_token')
|
||||
const [push] = useAccountStorage.object('push')
|
||||
const [domain] = useAccountStorage.string('auth.domain')
|
||||
const [accountId] = useAccountStorage.string('auth.account.id')
|
||||
const [accountAcct] = useAccountStorage.string('auth.account.acct')
|
||||
const [accountDomain] = useAccountStorage.string('auth.account.domain')
|
||||
const [accountId] = useAccountStorage.string('auth.account.id')
|
||||
|
||||
const appsQuery = useAppsQuery()
|
||||
|
||||
|
@ -119,7 +120,7 @@ const TabMePush: React.FC = () => {
|
|||
: null
|
||||
|
||||
const pushPath = `${expoToken}/${domain}/${accountId}`
|
||||
const accountFull = `@${accountAcct}@${domain}`
|
||||
const accountFull = `@${accountAcct}@${accountDomain}`
|
||||
|
||||
return (
|
||||
<ScrollView>
|
||||
|
@ -152,7 +153,7 @@ const TabMePush: React.FC = () => {
|
|||
) : null}
|
||||
<MenuContainer>
|
||||
<MenuRow
|
||||
title={t('me.push.global.heading', { acct: `@${accountAcct}@${domain}` })}
|
||||
title={t('me.push.global.heading', { acct: `@${accountAcct}@${accountDomain}` })}
|
||||
description={t('me.push.global.description')}
|
||||
switchDisabled={!pushEnabled}
|
||||
switchValue={pushEnabled === false ? false : push?.global}
|
||||
|
|
|
@ -38,7 +38,7 @@ const SettingsApp: React.FC = () => {
|
|||
// @ts-ignore
|
||||
LOCALES[
|
||||
Platform.OS === 'ios'
|
||||
? Localization.locale.toLowerCase().replace(new RegExp(/.*-.*(-.*)/, 'i'), '')
|
||||
? Localization.locale.replace(new RegExp(/.*-.*(-.*)/, 'i'), '')
|
||||
: i18n.language.toLowerCase()
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import Button from '@components/Button'
|
|||
import { MenuContainer, MenuRow } from '@components/Menu'
|
||||
import { displayMessage } from '@components/Message'
|
||||
import { useActionSheet } from '@expo/react-native-action-sheet'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles'
|
||||
import { storage } from '@utils/storage'
|
||||
import { getGlobalStorage, useGlobalStorage } from '@utils/storage/actions'
|
||||
|
@ -11,6 +12,7 @@ import React from 'react'
|
|||
import { MMKV } from 'react-native-mmkv'
|
||||
|
||||
const SettingsDev: React.FC = () => {
|
||||
const navigation = useNavigation()
|
||||
const { colors } = useTheme()
|
||||
const { showActionSheetWithOptions } = useActionSheet()
|
||||
|
||||
|
@ -54,16 +56,17 @@ const SettingsDev: React.FC = () => {
|
|||
destructive
|
||||
onPress={() => {
|
||||
const accounts = getGlobalStorage.object('accounts')
|
||||
if (!accounts) return
|
||||
|
||||
for (const account of accounts) {
|
||||
console.log('Clearing', account)
|
||||
const temp = new MMKV({ id: account })
|
||||
temp.clearAll()
|
||||
storage.account = undefined
|
||||
if (accounts) {
|
||||
for (const account of accounts) {
|
||||
console.log('Clearing', account)
|
||||
const temp = new MMKV({ id: account })
|
||||
temp.clearAll()
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Clearing', 'global')
|
||||
storage.global.clearAll()
|
||||
navigation.goBack()
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
|
|
|
@ -19,7 +19,7 @@ const AccountInformationAccount: React.FC<Props> = ({ account, myInfo }) => {
|
|||
const { colors } = useTheme()
|
||||
|
||||
const [acct] = useAccountStorage.string('auth.account.acct')
|
||||
const domain = getAccountStorage.string('auth.domain')
|
||||
const domain = getAccountStorage.string('auth.account.domain')
|
||||
|
||||
const { data: relationship } = useRelationshipQuery({
|
||||
id: account?.id || '',
|
||||
|
|
|
@ -74,7 +74,7 @@ const TabSharedReport: React.FC<TabSharedStackScreenProps<'Tab-Shared-Report'>>
|
|||
}, [isReporting, comment, forward, categories, rules])
|
||||
|
||||
const localInstance = account?.acct.includes('@')
|
||||
? account?.acct.includes(`@${getAccountStorage.string('auth.domain')}`)
|
||||
? account?.acct.includes(`@${getAccountStorage.string('auth.account.domain')}`)
|
||||
: true
|
||||
|
||||
const rulesQuery = useRulesQuery()
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue