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

@ -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) =>