mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Fix admin options not showing up
This commit is contained in:
@ -10,43 +10,39 @@ import { QueryKeyProfile } from '@utils/queryHooks/profile'
|
||||
import { getAccountDetails, getGlobalStorage } from '@utils/storage/actions'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
|
||||
export const PUSH_DEFAULT = [
|
||||
'follow',
|
||||
'follow_request',
|
||||
'favourite',
|
||||
'reblog',
|
||||
'mention',
|
||||
'poll',
|
||||
'update',
|
||||
'status'
|
||||
].filter(type => {
|
||||
switch (type) {
|
||||
case 'status':
|
||||
return featureCheck('notification_type_status')
|
||||
case 'update':
|
||||
return featureCheck('notification_type_update')
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}) as ['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'poll', 'update', 'status']
|
||||
export const PUSH_DEFAULT = () =>
|
||||
['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'poll', 'update', 'status'].filter(
|
||||
type => {
|
||||
switch (type) {
|
||||
case 'status':
|
||||
return featureCheck('notification_type_status')
|
||||
case 'update':
|
||||
return featureCheck('notification_type_update')
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
) as ['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'poll', 'update', 'status']
|
||||
|
||||
export const PUSH_ADMIN = [
|
||||
{ type: 'admin.sign_up', permission: PERMISSION_MANAGE_USERS },
|
||||
{ type: 'admin.report', permission: PERMISSION_MANAGE_REPORTS }
|
||||
].filter(({ type, permission }) => {
|
||||
const queryKeyProfile: QueryKeyProfile = ['Profile']
|
||||
const permissions = queryClient.getQueryData<Mastodon.Account>(queryKeyProfile)?.role?.permissions
|
||||
switch (type) {
|
||||
case 'admin.sign_up':
|
||||
return (
|
||||
featureCheck('notification_type_admin_signup') && checkPermission(permission, permissions)
|
||||
)
|
||||
case 'admin.report':
|
||||
return (
|
||||
featureCheck('notification_type_admin_report') && checkPermission(permission, permissions)
|
||||
)
|
||||
}
|
||||
}) as { type: 'admin.sign_up' | 'admin.report'; permission: number }[]
|
||||
export const PUSH_ADMIN = () =>
|
||||
[
|
||||
{ type: 'admin.sign_up', permission: PERMISSION_MANAGE_USERS },
|
||||
{ type: 'admin.report', permission: PERMISSION_MANAGE_REPORTS }
|
||||
].filter(({ type, permission }) => {
|
||||
const queryKeyProfile: QueryKeyProfile = ['Profile']
|
||||
const permissions =
|
||||
queryClient.getQueryData<Mastodon.Account>(queryKeyProfile)?.role?.permissions
|
||||
switch (type) {
|
||||
case 'admin.sign_up':
|
||||
return (
|
||||
featureCheck('notification_type_admin_signup') && checkPermission(permission, permissions)
|
||||
)
|
||||
case 'admin.report':
|
||||
return (
|
||||
featureCheck('notification_type_admin_report') && checkPermission(permission, permissions)
|
||||
)
|
||||
}
|
||||
}) as { type: 'admin.sign_up' | 'admin.report'; permission: number }[]
|
||||
|
||||
export const setChannels = async (reset: boolean | undefined = false, specificAccount?: string) => {
|
||||
const account = specificAccount || getGlobalStorage.string('account.active')
|
||||
@ -76,18 +72,18 @@ export const setChannels = async (reset: boolean | undefined = false, specificAc
|
||||
|
||||
if (!accountDetails.push.decode) {
|
||||
await setChannel('default')
|
||||
for (const push of PUSH_DEFAULT) {
|
||||
for (const push of PUSH_DEFAULT()) {
|
||||
await deleteChannel(push)
|
||||
}
|
||||
for (const { type } of PUSH_ADMIN) {
|
||||
for (const { type } of PUSH_ADMIN()) {
|
||||
await deleteChannel(type)
|
||||
}
|
||||
} else {
|
||||
await deleteChannel('default')
|
||||
for (const push of PUSH_DEFAULT) {
|
||||
for (const push of PUSH_DEFAULT()) {
|
||||
await setChannel(push)
|
||||
}
|
||||
for (const { type } of PUSH_ADMIN) {
|
||||
for (const { type } of PUSH_ADMIN()) {
|
||||
await setChannel(type)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,11 @@ const useProfileQuery = (
|
||||
options: UseQueryOptions<AccountWithSource, AxiosError>
|
||||
} | void
|
||||
) => {
|
||||
return useQuery(queryKey, queryFunctionProfile, params?.options)
|
||||
return useQuery(queryKey, queryFunctionProfile, {
|
||||
...params?.options,
|
||||
staleTime: Infinity,
|
||||
cacheTime: Infinity
|
||||
})
|
||||
}
|
||||
|
||||
type MutationVarsProfileBase =
|
||||
|
Reference in New Issue
Block a user