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-Core
|
||||||
- react-native-language-detection (0.2.2):
|
- react-native-language-detection (0.2.2):
|
||||||
- React
|
- React
|
||||||
- react-native-menu (0.7.2):
|
- react-native-menu (0.7.3):
|
||||||
- React
|
- React
|
||||||
- react-native-mmkv (2.5.1):
|
- react-native-mmkv (2.5.1):
|
||||||
- MMKV (>= 1.2.13)
|
- MMKV (>= 1.2.13)
|
||||||
|
@ -748,7 +748,7 @@ SPEC CHECKSUMS:
|
||||||
react-native-image-picker: 60f4246eb5bb7187fc15638a8c1f13abd3820695
|
react-native-image-picker: 60f4246eb5bb7187fc15638a8c1f13abd3820695
|
||||||
react-native-ios-context-menu: b170594b4448c0cd10c79e13432216bac99de1ac
|
react-native-ios-context-menu: b170594b4448c0cd10c79e13432216bac99de1ac
|
||||||
react-native-language-detection: f414937fa715108ab50a6269a3de0bcb95e4ceb0
|
react-native-language-detection: f414937fa715108ab50a6269a3de0bcb95e4ceb0
|
||||||
react-native-menu: 8e172cfcf0e42e92f028e7781eddf84d430cae24
|
react-native-menu: 9d7d6f819cc7fa14a15cf86888c53f3240d86f1b
|
||||||
react-native-mmkv: 69b9c003f10afdd01addf7c6ee784ce42ee2eff3
|
react-native-mmkv: 69b9c003f10afdd01addf7c6ee784ce42ee2eff3
|
||||||
react-native-netinfo: 2517ad504b3d303e90d7a431b0fcaef76d207983
|
react-native-netinfo: 2517ad504b3d303e90d7a431b0fcaef76d207983
|
||||||
react-native-pager-view: 54bed894cecebe28cede54c01038d9d1e122de43
|
react-native-pager-view: 54bed894cecebe28cede54c01038d9d1e122de43
|
||||||
|
|
|
@ -86,5 +86,7 @@
|
||||||
<string>Automatic</string>
|
<string>Automatic</string>
|
||||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
<false/>
|
<false/>
|
||||||
|
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -15,7 +15,7 @@ interface Props {
|
||||||
const AccountButton: React.FC<Props> = ({ account, selected = false, additionalActions }) => {
|
const AccountButton: React.FC<Props> = ({ account, selected = false, additionalActions }) => {
|
||||||
const navigation = useNavigation()
|
const navigation = useNavigation()
|
||||||
const accountDetails = getAccountDetails(
|
const accountDetails = getAccountDetails(
|
||||||
['auth.account.acct', 'auth.domain', 'auth.account.id'],
|
['auth.domain', 'auth.account.acct', 'auth.account.domain', 'auth.account.id'],
|
||||||
account
|
account
|
||||||
)
|
)
|
||||||
if (!accountDetails) return null
|
if (!accountDetails) return null
|
||||||
|
@ -28,7 +28,7 @@ const AccountButton: React.FC<Props> = ({ account, selected = false, additionalA
|
||||||
marginBottom: StyleConstants.Spacing.M,
|
marginBottom: StyleConstants.Spacing.M,
|
||||||
marginRight: 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 ? ' ✓' : ''
|
selected ? ' ✓' : ''
|
||||||
}`}
|
}`}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
|
|
@ -123,6 +123,8 @@ const ComponentInstance: React.FC<Props> = ({
|
||||||
'auth.domain': domain,
|
'auth.domain': domain,
|
||||||
'auth.account.id': id,
|
'auth.account.id': id,
|
||||||
'auth.account.acct': acct,
|
'auth.account.acct': acct,
|
||||||
|
// @ts-ignore
|
||||||
|
'auth.account.domain': instanceQuery.data?.domain || instanceQuery.data?.uri,
|
||||||
'auth.account.avatar_static': avatar_static,
|
'auth.account.avatar_static': avatar_static,
|
||||||
version: instanceQuery.data?.version || '0',
|
version: instanceQuery.data?.version || '0',
|
||||||
preferences: undefined,
|
preferences: undefined,
|
||||||
|
|
|
@ -23,7 +23,7 @@ const ComposePostingAs = () => {
|
||||||
<CustomText fontStyle='S' style={{ color: colors.secondary }}>
|
<CustomText fontStyle='S' style={{ color: colors.secondary }}>
|
||||||
{t('content.root.header.postingAs', {
|
{t('content.root.header.postingAs', {
|
||||||
acct: getAccountStorage.string('auth.account.acct'),
|
acct: getAccountStorage.string('auth.account.acct'),
|
||||||
domain: getAccountStorage.string('auth.domain')
|
domain: getAccountStorage.string('auth.account.domain')
|
||||||
})}
|
})}
|
||||||
</CustomText>
|
</CustomText>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -29,8 +29,9 @@ const TabMePush: React.FC = () => {
|
||||||
const [expoToken] = useGlobalStorage.string('app.expo_token')
|
const [expoToken] = useGlobalStorage.string('app.expo_token')
|
||||||
const [push] = useAccountStorage.object('push')
|
const [push] = useAccountStorage.object('push')
|
||||||
const [domain] = useAccountStorage.string('auth.domain')
|
const [domain] = useAccountStorage.string('auth.domain')
|
||||||
const [accountId] = useAccountStorage.string('auth.account.id')
|
|
||||||
const [accountAcct] = useAccountStorage.string('auth.account.acct')
|
const [accountAcct] = useAccountStorage.string('auth.account.acct')
|
||||||
|
const [accountDomain] = useAccountStorage.string('auth.account.domain')
|
||||||
|
const [accountId] = useAccountStorage.string('auth.account.id')
|
||||||
|
|
||||||
const appsQuery = useAppsQuery()
|
const appsQuery = useAppsQuery()
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ const TabMePush: React.FC = () => {
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const pushPath = `${expoToken}/${domain}/${accountId}`
|
const pushPath = `${expoToken}/${domain}/${accountId}`
|
||||||
const accountFull = `@${accountAcct}@${domain}`
|
const accountFull = `@${accountAcct}@${accountDomain}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
|
@ -152,7 +153,7 @@ const TabMePush: React.FC = () => {
|
||||||
) : null}
|
) : null}
|
||||||
<MenuContainer>
|
<MenuContainer>
|
||||||
<MenuRow
|
<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')}
|
description={t('me.push.global.description')}
|
||||||
switchDisabled={!pushEnabled}
|
switchDisabled={!pushEnabled}
|
||||||
switchValue={pushEnabled === false ? false : push?.global}
|
switchValue={pushEnabled === false ? false : push?.global}
|
||||||
|
|
|
@ -38,7 +38,7 @@ const SettingsApp: React.FC = () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
LOCALES[
|
LOCALES[
|
||||||
Platform.OS === 'ios'
|
Platform.OS === 'ios'
|
||||||
? Localization.locale.toLowerCase().replace(new RegExp(/.*-.*(-.*)/, 'i'), '')
|
? Localization.locale.replace(new RegExp(/.*-.*(-.*)/, 'i'), '')
|
||||||
: i18n.language.toLowerCase()
|
: i18n.language.toLowerCase()
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import Button from '@components/Button'
|
||||||
import { MenuContainer, MenuRow } from '@components/Menu'
|
import { MenuContainer, MenuRow } from '@components/Menu'
|
||||||
import { displayMessage } from '@components/Message'
|
import { displayMessage } from '@components/Message'
|
||||||
import { useActionSheet } from '@expo/react-native-action-sheet'
|
import { useActionSheet } from '@expo/react-native-action-sheet'
|
||||||
|
import { useNavigation } from '@react-navigation/native'
|
||||||
import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles'
|
import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles'
|
||||||
import { storage } from '@utils/storage'
|
import { storage } from '@utils/storage'
|
||||||
import { getGlobalStorage, useGlobalStorage } from '@utils/storage/actions'
|
import { getGlobalStorage, useGlobalStorage } from '@utils/storage/actions'
|
||||||
|
@ -11,6 +12,7 @@ import React from 'react'
|
||||||
import { MMKV } from 'react-native-mmkv'
|
import { MMKV } from 'react-native-mmkv'
|
||||||
|
|
||||||
const SettingsDev: React.FC = () => {
|
const SettingsDev: React.FC = () => {
|
||||||
|
const navigation = useNavigation()
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
const { showActionSheetWithOptions } = useActionSheet()
|
const { showActionSheetWithOptions } = useActionSheet()
|
||||||
|
|
||||||
|
@ -54,16 +56,17 @@ const SettingsDev: React.FC = () => {
|
||||||
destructive
|
destructive
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
const accounts = getGlobalStorage.object('accounts')
|
const accounts = getGlobalStorage.object('accounts')
|
||||||
if (!accounts) return
|
storage.account = undefined
|
||||||
|
if (accounts) {
|
||||||
for (const account of accounts) {
|
for (const account of accounts) {
|
||||||
console.log('Clearing', account)
|
console.log('Clearing', account)
|
||||||
const temp = new MMKV({ id: account })
|
const temp = new MMKV({ id: account })
|
||||||
temp.clearAll()
|
temp.clearAll()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Clearing', 'global')
|
console.log('Clearing', 'global')
|
||||||
storage.global.clearAll()
|
storage.global.clearAll()
|
||||||
|
navigation.goBack()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -19,7 +19,7 @@ const AccountInformationAccount: React.FC<Props> = ({ account, myInfo }) => {
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
|
|
||||||
const [acct] = useAccountStorage.string('auth.account.acct')
|
const [acct] = useAccountStorage.string('auth.account.acct')
|
||||||
const domain = getAccountStorage.string('auth.domain')
|
const domain = getAccountStorage.string('auth.account.domain')
|
||||||
|
|
||||||
const { data: relationship } = useRelationshipQuery({
|
const { data: relationship } = useRelationshipQuery({
|
||||||
id: account?.id || '',
|
id: account?.id || '',
|
||||||
|
|
|
@ -74,7 +74,7 @@ const TabSharedReport: React.FC<TabSharedStackScreenProps<'Tab-Shared-Report'>>
|
||||||
}, [isReporting, comment, forward, categories, rules])
|
}, [isReporting, comment, forward, categories, rules])
|
||||||
|
|
||||||
const localInstance = account?.acct.includes('@')
|
const localInstance = account?.acct.includes('@')
|
||||||
? account?.acct.includes(`@${getAccountStorage.string('auth.domain')}`)
|
? account?.acct.includes(`@${getAccountStorage.string('auth.account.domain')}`)
|
||||||
: true
|
: true
|
||||||
|
|
||||||
const rulesQuery = useRulesQuery()
|
const rulesQuery = useRulesQuery()
|
||||||
|
|
|
@ -18,9 +18,10 @@ export type AccountV0 = {
|
||||||
'auth.clientId': string
|
'auth.clientId': string
|
||||||
'auth.clientSecret': string
|
'auth.clientSecret': string
|
||||||
'auth.token': string
|
'auth.token': string
|
||||||
'auth.domain': string
|
'auth.domain': string // used for API
|
||||||
'auth.account.id': string
|
'auth.account.id': string
|
||||||
'auth.account.acct': string
|
'auth.account.acct': string
|
||||||
|
'auth.account.domain': string // used for username
|
||||||
'auth.account.avatar_static': string
|
'auth.account.avatar_static': string
|
||||||
version: string
|
version: string
|
||||||
// number
|
// number
|
||||||
|
|
|
@ -24,10 +24,16 @@ export const getGlobalStorage = {
|
||||||
storage.global.getBoolean(key) as NonNullable<StorageGlobal[T]> extends boolean
|
storage.global.getBoolean(key) as NonNullable<StorageGlobal[T]> extends boolean
|
||||||
? StorageGlobal[T]
|
? StorageGlobal[T]
|
||||||
: never,
|
: never,
|
||||||
object: <T extends keyof StorageGlobal>(key: T) =>
|
object: <T extends keyof StorageGlobal>(key: T) => {
|
||||||
JSON.parse(storage.global.getString(key) || '') as NonNullable<StorageGlobal[T]> extends object
|
const value = storage.global.getString(key)
|
||||||
? StorageGlobal[T]
|
if (value?.length) {
|
||||||
: never
|
return JSON.parse(value) as NonNullable<StorageGlobal[T]> extends object
|
||||||
|
? StorageGlobal[T]
|
||||||
|
: never
|
||||||
|
} else {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export const useGlobalStorage = {
|
export const useGlobalStorage = {
|
||||||
string: <T extends keyof StorageGlobal>(key: T) =>
|
string: <T extends keyof StorageGlobal>(key: T) =>
|
||||||
|
@ -84,7 +90,7 @@ export const getAccountStorage = {
|
||||||
: never,
|
: never,
|
||||||
object: <T extends keyof StorageAccount>(key: T) => {
|
object: <T extends keyof StorageAccount>(key: T) => {
|
||||||
const value = storage.account?.getString(key)
|
const value = storage.account?.getString(key)
|
||||||
if (value) {
|
if (value?.length) {
|
||||||
return JSON.parse(value) as NonNullable<StorageAccount[T]> extends object
|
return JSON.parse(value) as NonNullable<StorageAccount[T]> extends object
|
||||||
? StorageAccount[T]
|
? StorageAccount[T]
|
||||||
: never
|
: never
|
||||||
|
@ -166,8 +172,9 @@ export const getAccountDetails = <T extends Array<keyof StorageAccount>>(
|
||||||
case 'auth.clientSecret':
|
case 'auth.clientSecret':
|
||||||
case 'auth.token':
|
case 'auth.token':
|
||||||
case 'auth.domain':
|
case 'auth.domain':
|
||||||
case 'auth.account.id':
|
|
||||||
case 'auth.account.acct':
|
case 'auth.account.acct':
|
||||||
|
case 'auth.account.domain':
|
||||||
|
case 'auth.account.id':
|
||||||
case 'auth.account.avatar_static':
|
case 'auth.account.avatar_static':
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
result[key] = temp.getString(key)
|
result[key] = temp.getString(key)
|
||||||
|
@ -180,9 +187,12 @@ export const getAccountDetails = <T extends Array<keyof StorageAccount>>(
|
||||||
case 'drafts':
|
case 'drafts':
|
||||||
case 'emojis_frequent':
|
case 'emojis_frequent':
|
||||||
const value = temp.getString(key)
|
const value = temp.getString(key)
|
||||||
if (value) {
|
if (value?.length) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
result[key] = JSON.parse(value)
|
result[key] = JSON.parse(value)
|
||||||
|
} else {
|
||||||
|
// @ts-ignore
|
||||||
|
result[key] = undefined
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,16 +67,17 @@ export async function migrateFromAsyncStorage(): Promise<void> {
|
||||||
const accounts: string[] = []
|
const accounts: string[] = []
|
||||||
|
|
||||||
for (const instance of JSON.parse(storeInstances.instances)) {
|
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 })
|
const temp = new MMKV({ id: account })
|
||||||
temp.set('auth.clientId', instance.appData.clientId)
|
temp.set('auth.clientId', instance.appData.clientId)
|
||||||
temp.set('auth.clientSecret', instance.appData.clientSecret)
|
temp.set('auth.clientSecret', instance.appData.clientSecret)
|
||||||
temp.set('auth.token', instance.token)
|
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.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)
|
temp.set('auth.account.avatar_static', instance.account.avatarStatic)
|
||||||
|
|
||||||
if (instance.account.preferences) {
|
if (instance.account.preferences) {
|
||||||
|
|
Loading…
Reference in New Issue