1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Lots of updates

This commit is contained in:
Zhiyuan Zheng
2020-11-24 00:18:47 +01:00
parent fba1d0d531
commit 8200375c92
23 changed files with 378 additions and 152 deletions

View File

@ -0,0 +1,9 @@
const getCurrentTab = (navigation: any) => {
const {
length,
[length - 1]: last
} = navigation.dangerouslyGetState().history
return `Screen-${last.key.split(new RegExp(/Screen-(.*?)-/))[1]}`
}
export default getCurrentTab

View File

@ -17,15 +17,34 @@ export type InstancesState = {
}
}
const initialStateLocal = {
url: undefined,
token: undefined,
account: {
id: undefined,
preferences: {
'posting:default:visibility': undefined,
'posting:default:sensitive': undefined,
'posting:default:language': undefined,
'reading:expand:media': undefined,
'reading:expand:spoilers': undefined
}
}
}
export const updateLocal = createAsyncThunk(
'instances/updateLocal',
async ({
url,
token
}: {
url: InstancesState['local']['url']
token: InstancesState['local']['token']
url?: InstancesState['local']['url']
token?: InstancesState['local']['token']
}) => {
if (!url || !token) {
return initialStateLocal
}
const {
body: { id }
} = await client({
@ -58,22 +77,9 @@ export const updateLocal = createAsyncThunk(
const instancesSlice = createSlice({
name: 'instances',
initialState: {
local: {
url: undefined,
token: undefined,
account: {
id: undefined,
preferences: {
'posting:default:visibility': undefined,
'posting:default:sensitive': undefined,
'posting:default:language': undefined,
'reading:expand:media': undefined,
'reading:expand:spoilers': undefined
}
}
},
local: initialStateLocal,
remote: {
url: 'mastodon.social'
url: 'm.cmx.im'
}
} as InstancesState,
reducers: {},
@ -85,6 +91,7 @@ const instancesSlice = createSlice({
})
export const getLocalUrl = (state: RootState) => state.instances.local.url
export const getRemoteUrl = (state: RootState) => state.instances.remote.url
export const getLocalAccountId = (state: RootState) =>
state.instances.local.account.id
export const getLocalAccountPreferences = (state: RootState) =>

View File

@ -3,6 +3,8 @@ export default {
FONT_SIZE_M: 14,
FONT_SIZE_L: 18,
FONT_WEIGHT_BOLD: '600',
SPACING_XS: 4,
SPACING_S: 8,
SPACING_M: 16,

View File

@ -7,6 +7,7 @@ export type ColorDefinitions =
| 'link'
| 'border'
| 'separator'
| 'dangerous'
const themeColors: {
[key in ColorDefinitions]: {
@ -37,6 +38,10 @@ const themeColors: {
separator: {
light: 'rgba(0, 0, 0, 0.1)',
dark: 'rgba(255, 255, 255, 0.1)'
},
dangerous: {
light: 'rgb(255, 59, 48)',
dark: 'rgb(255, 69, 58)'
}
}