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

Added notifications filter

This commit is contained in:
Zhiyuan Zheng
2021-03-17 15:30:28 +01:00
parent d03d5600ec
commit 03b312fefe
20 changed files with 390 additions and 64 deletions

View File

@ -29,6 +29,14 @@ export type Instance = {
avatarStatic: Mastodon.Account['avatar_static']
preferences: Mastodon.Preferences
}
notifications_filter: {
follow: boolean
favourite: boolean
reblog: boolean
mention: boolean
poll: boolean
follow_request: boolean
}
push:
| {
global: { loading: boolean; value: boolean }
@ -55,13 +63,11 @@ export type Instance = {
value: Mastodon.PushSubscription['alerts']['poll']
}
}
keys:
| {
auth: string
public: string
private: string
}
| undefined
keys: {
auth: string
public: string
private: string
}
}
| {
global: { loading: boolean; value: boolean }
@ -127,6 +133,13 @@ const instancesSlice = createSlice({
...action.payload
}
},
updateInstanceNotificationsFilter: (
{ instances },
action: PayloadAction<Instance['notifications_filter']>
) => {
const activeIndex = findInstanceActive(instances)
instances[activeIndex].notifications_filter = action.payload
},
updateInstanceDraft: (
{ instances },
action: PayloadAction<ComposeStateDraft>
@ -314,6 +327,15 @@ export const getInstanceAccount = ({ instances: { instances } }: RootState) => {
return instanceActive !== -1 ? instances[instanceActive].account : null
}
export const getInstanceNotificationsFilter = ({
instances: { instances }
}: RootState) => {
const instanceActive = findInstanceActive(instances)
return instanceActive !== -1
? instances[instanceActive].notifications_filter
: null
}
export const getInstancePush = ({ instances: { instances } }: RootState) => {
const instanceActive = findInstanceActive(instances)
return instanceActive !== -1 ? instances[instanceActive].push : null
@ -327,6 +349,7 @@ export const getInstanceDrafts = ({ instances: { instances } }: RootState) => {
export const {
updateInstanceActive,
updateInstanceAccount,
updateInstanceNotificationsFilter,
updateInstanceDraft,
removeInstanceDraft,
disableAllPushes