mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Removed webhook notification
This commit is contained in:
@ -70,10 +70,6 @@ const addInstance = createAsyncThunk(
|
||||
avatarStatic: avatar_static,
|
||||
preferences
|
||||
},
|
||||
notification: {
|
||||
readTime: undefined,
|
||||
latestTime: undefined
|
||||
},
|
||||
push: {
|
||||
global: { loading: false, value: false },
|
||||
decode: { loading: false, value: false },
|
||||
|
@ -85,8 +85,6 @@ const pushRegister = async (
|
||||
accountId,
|
||||
accountFull
|
||||
})
|
||||
console.log('endpoint', serverRes.body.endpoint)
|
||||
console.log('token', instance?.token)
|
||||
|
||||
const alerts = instancePush.alerts
|
||||
const formData = new FormData()
|
||||
|
@ -1,39 +1,37 @@
|
||||
import { createAsyncThunk } from '@reduxjs/toolkit'
|
||||
import { RootState } from '@root/store'
|
||||
import * as AuthSession from 'expo-auth-session'
|
||||
import { Instance } from '../instancesSlice'
|
||||
import { updateInstancePush } from './updatePush'
|
||||
|
||||
const removeInstance = createAsyncThunk(
|
||||
'instances/remove',
|
||||
async (index: number): Promise<number> => {
|
||||
const { store } = require('@root/store')
|
||||
const instances = (store.getState() as RootState).instances.instances
|
||||
|
||||
if (index !== -1) {
|
||||
const currentInstance = instances[index]
|
||||
|
||||
let revoked = undefined
|
||||
try {
|
||||
revoked = await AuthSession.revokeAsync(
|
||||
{
|
||||
clientId: currentInstance.appData.clientId,
|
||||
clientSecret: currentInstance.appData.clientSecret,
|
||||
token: currentInstance.token,
|
||||
scopes: ['read', 'write', 'follow', 'push']
|
||||
},
|
||||
{
|
||||
revocationEndpoint: `https://${currentInstance.url}/oauth/revoke`
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
console.warn('Revoking error')
|
||||
}
|
||||
|
||||
if (!revoked) {
|
||||
console.warn('Revoking error')
|
||||
}
|
||||
async (instance: Instance, { dispatch }): Promise<Instance> => {
|
||||
if (instance.push.global.value) {
|
||||
dispatch(updateInstancePush(false))
|
||||
}
|
||||
|
||||
return Promise.resolve(index)
|
||||
let revoked = undefined
|
||||
try {
|
||||
revoked = await AuthSession.revokeAsync(
|
||||
{
|
||||
clientId: instance.appData.clientId,
|
||||
clientSecret: instance.appData.clientSecret,
|
||||
token: instance.token,
|
||||
scopes: ['read', 'write', 'follow', 'push']
|
||||
},
|
||||
{
|
||||
revocationEndpoint: `https://${instance.url}/oauth/revoke`
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
console.warn('Revoking error')
|
||||
}
|
||||
|
||||
if (!revoked) {
|
||||
console.warn('Revoking error')
|
||||
}
|
||||
|
||||
return Promise.resolve(instance)
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -29,10 +29,6 @@ export type Instance = {
|
||||
avatarStatic: Mastodon.Account['avatar_static']
|
||||
preferences: Mastodon.Preferences
|
||||
}
|
||||
notification: {
|
||||
readTime?: Mastodon.Notification['created_at']
|
||||
latestTime?: Mastodon.Notification['created_at']
|
||||
}
|
||||
push:
|
||||
| {
|
||||
global: { loading: boolean; value: true }
|
||||
@ -129,16 +125,6 @@ const instancesSlice = createSlice({
|
||||
...action.payload
|
||||
}
|
||||
},
|
||||
updateInstanceNotification: (
|
||||
{ instances },
|
||||
action: PayloadAction<Partial<Instance['notification']>>
|
||||
) => {
|
||||
const activeIndex = findInstanceActive(instances)
|
||||
instances[activeIndex].notification = {
|
||||
...instances[activeIndex].notification,
|
||||
...action.payload
|
||||
}
|
||||
},
|
||||
updateInstanceDraft: (
|
||||
{ instances },
|
||||
action: PayloadAction<ComposeStateDraft>
|
||||
@ -198,7 +184,16 @@ const instancesSlice = createSlice({
|
||||
})
|
||||
|
||||
.addCase(removeInstance.fulfilled, (state, action) => {
|
||||
state.instances.splice(action.payload, 1)
|
||||
state.instances = state.instances.filter(instance => {
|
||||
if (
|
||||
instance.url === action.payload.url &&
|
||||
instance.account.id === action.payload.account.id
|
||||
) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
})
|
||||
state.instances.length &&
|
||||
(state.instances[state.instances.length - 1].active = true)
|
||||
|
||||
@ -310,13 +305,6 @@ export const getInstanceAccount = ({ instances: { instances } }: RootState) => {
|
||||
return instanceActive !== -1 ? instances[instanceActive].account : null
|
||||
}
|
||||
|
||||
export const getInstanceNotification = ({
|
||||
instances: { instances }
|
||||
}: RootState) => {
|
||||
const instanceActive = findInstanceActive(instances)
|
||||
return instanceActive !== -1 ? instances[instanceActive].notification : null
|
||||
}
|
||||
|
||||
export const getInstancePush = ({ instances: { instances } }: RootState) => {
|
||||
const instanceActive = findInstanceActive(instances)
|
||||
return instanceActive !== -1 ? instances[instanceActive].push : null
|
||||
@ -330,7 +318,6 @@ export const getInstanceDrafts = ({ instances: { instances } }: RootState) => {
|
||||
export const {
|
||||
updateInstanceActive,
|
||||
updateInstanceAccount,
|
||||
updateInstanceNotification,
|
||||
updateInstanceDraft,
|
||||
removeInstanceDraft
|
||||
} = instancesSlice.actions
|
||||
|
Reference in New Issue
Block a user