1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00
This commit is contained in:
Zhiyuan Zheng
2021-01-17 22:37:05 +01:00
parent 813f6b57c4
commit f977fdfa8b
44 changed files with 252 additions and 158 deletions

View File

@ -3,6 +3,7 @@ import analytics from '@components/analytics'
import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit'
import { RootState } from '@root/store'
import * as AuthSession from 'expo-auth-session'
import * as Localization from 'expo-localization'
export type InstanceLocal = {
appData: {
@ -11,6 +12,7 @@ export type InstanceLocal = {
}
url: string
token: string
uri: Mastodon.Instance['uri']
account: {
id: Mastodon.Account['id']
preferences: Mastodon.Preferences
@ -50,10 +52,12 @@ export const localAddInstance = createAsyncThunk(
async ({
url,
token,
uri,
appData
}: {
url: InstanceLocal['url']
token: InstanceLocal['token']
uri: Mastodon.Instance['uri']
appData: InstanceLocal['appData']
}): Promise<{ type: 'add' | 'overwrite'; data: InstanceLocal }> => {
const { store } = require('@root/store')
@ -101,6 +105,7 @@ export const localAddInstance = createAsyncThunk(
appData,
url,
token,
uri,
account: {
id,
preferences
@ -159,7 +164,7 @@ export const instancesInitialState: InstancesState = {
instances: []
},
remote: {
url: 'm.cmx.im'
url: Localization.locale.includes('zh') ? 'm.cmx.im' : 'mastodon.social'
}
}

View File

@ -1,16 +1,19 @@
import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit'
import { RootState } from '@root/store'
import * as Analytics from 'expo-firebase-analytics'
import * as Localization from 'expo-localization'
export const supportedLngs = ['zh-Hans', 'en']
export type SettingsState = {
language: 'zh-CN' | 'en-US' | undefined
language: 'zh-Hans' | 'en'
theme: 'light' | 'dark' | 'auto'
browser: 'internal' | 'external'
analytics: boolean
}
export const settingsInitialState = {
language: undefined,
language: Localization.locale,
theme: 'auto',
browser: 'internal',
analytics: true