mirror of https://github.com/tooot-app/app
Fix admin options not showing up
This commit is contained in:
parent
43a98be2d9
commit
a77e495b6b
|
@ -192,7 +192,7 @@ const ComponentInstance: React.FC<Props> = ({
|
||||||
const processUpdate = useCallback(() => {
|
const processUpdate = useCallback(() => {
|
||||||
if (domain) {
|
if (domain) {
|
||||||
const accounts = getGlobalStorage.object('accounts')
|
const accounts = getGlobalStorage.object('accounts')
|
||||||
if (accounts && accounts.filter(account => account.startsWith(`${domain}/`)).length) {
|
if (accounts?.filter(account => account.startsWith(`${domain}/`)).length) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
t('componentInstance:update.alert.title'),
|
t('componentInstance:update.alert.title'),
|
||||||
t('componentInstance:update.alert.message'),
|
t('componentInstance:update.alert.message'),
|
||||||
|
|
|
@ -66,7 +66,7 @@ const TabMePush: React.FC = () => {
|
||||||
|
|
||||||
const alerts = () =>
|
const alerts = () =>
|
||||||
push?.alerts
|
push?.alerts
|
||||||
? PUSH_DEFAULT.map(alert => (
|
? PUSH_DEFAULT().map(alert => (
|
||||||
<MenuRow
|
<MenuRow
|
||||||
key={alert}
|
key={alert}
|
||||||
title={t(`me.push.${alert}.heading`)}
|
title={t(`me.push.${alert}.heading`)}
|
||||||
|
@ -94,7 +94,7 @@ const TabMePush: React.FC = () => {
|
||||||
const profileQuery = useProfileQuery()
|
const profileQuery = useProfileQuery()
|
||||||
const adminAlerts = () =>
|
const adminAlerts = () =>
|
||||||
profileQuery.data?.role?.permissions
|
profileQuery.data?.role?.permissions
|
||||||
? PUSH_ADMIN.map(({ type }) => (
|
? PUSH_ADMIN().map(({ type }) => (
|
||||||
<MenuRow
|
<MenuRow
|
||||||
key={type}
|
key={type}
|
||||||
title={t(`me.push.${type}.heading`)}
|
title={t(`me.push.${type}.heading`)}
|
||||||
|
|
|
@ -66,7 +66,7 @@ const TabNotificationsFilters: React.FC<
|
||||||
return (
|
return (
|
||||||
<ScrollView style={{ flex: 1 }}>
|
<ScrollView style={{ flex: 1 }}>
|
||||||
<MenuContainer>
|
<MenuContainer>
|
||||||
{PUSH_DEFAULT.map((type, index) => (
|
{PUSH_DEFAULT().map((type, index) => (
|
||||||
<MenuRow
|
<MenuRow
|
||||||
key={index}
|
key={index}
|
||||||
title={t(`screenTabs:me.push.${type}.heading`)}
|
title={t(`screenTabs:me.push.${type}.heading`)}
|
||||||
|
@ -74,7 +74,9 @@ const TabNotificationsFilters: React.FC<
|
||||||
switchOnValueChange={() => setFilters({ ...filters, [type]: !filters[type] })}
|
switchOnValueChange={() => setFilters({ ...filters, [type]: !filters[type] })}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{PUSH_ADMIN.map(({ type }) => (
|
</MenuContainer>
|
||||||
|
<MenuContainer>
|
||||||
|
{PUSH_ADMIN().map(({ type }) => (
|
||||||
<MenuRow
|
<MenuRow
|
||||||
key={type}
|
key={type}
|
||||||
title={t(`screenTabs:me.push.${type}.heading`)}
|
title={t(`screenTabs:me.push.${type}.heading`)}
|
||||||
|
|
|
@ -10,43 +10,39 @@ import { QueryKeyProfile } from '@utils/queryHooks/profile'
|
||||||
import { getAccountDetails, getGlobalStorage } from '@utils/storage/actions'
|
import { getAccountDetails, getGlobalStorage } from '@utils/storage/actions'
|
||||||
import * as Notifications from 'expo-notifications'
|
import * as Notifications from 'expo-notifications'
|
||||||
|
|
||||||
export const PUSH_DEFAULT = [
|
export const PUSH_DEFAULT = () =>
|
||||||
'follow',
|
['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'poll', 'update', 'status'].filter(
|
||||||
'follow_request',
|
type => {
|
||||||
'favourite',
|
switch (type) {
|
||||||
'reblog',
|
case 'status':
|
||||||
'mention',
|
return featureCheck('notification_type_status')
|
||||||
'poll',
|
case 'update':
|
||||||
'update',
|
return featureCheck('notification_type_update')
|
||||||
'status'
|
default:
|
||||||
].filter(type => {
|
return true
|
||||||
switch (type) {
|
}
|
||||||
case 'status':
|
}
|
||||||
return featureCheck('notification_type_status')
|
) as ['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'poll', 'update', '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 = [
|
export const PUSH_ADMIN = () =>
|
||||||
{ type: 'admin.sign_up', permission: PERMISSION_MANAGE_USERS },
|
[
|
||||||
{ type: 'admin.report', permission: PERMISSION_MANAGE_REPORTS }
|
{ type: 'admin.sign_up', permission: PERMISSION_MANAGE_USERS },
|
||||||
].filter(({ type, permission }) => {
|
{ type: 'admin.report', permission: PERMISSION_MANAGE_REPORTS }
|
||||||
const queryKeyProfile: QueryKeyProfile = ['Profile']
|
].filter(({ type, permission }) => {
|
||||||
const permissions = queryClient.getQueryData<Mastodon.Account>(queryKeyProfile)?.role?.permissions
|
const queryKeyProfile: QueryKeyProfile = ['Profile']
|
||||||
switch (type) {
|
const permissions =
|
||||||
case 'admin.sign_up':
|
queryClient.getQueryData<Mastodon.Account>(queryKeyProfile)?.role?.permissions
|
||||||
return (
|
switch (type) {
|
||||||
featureCheck('notification_type_admin_signup') && checkPermission(permission, permissions)
|
case 'admin.sign_up':
|
||||||
)
|
return (
|
||||||
case 'admin.report':
|
featureCheck('notification_type_admin_signup') && checkPermission(permission, permissions)
|
||||||
return (
|
)
|
||||||
featureCheck('notification_type_admin_report') && checkPermission(permission, permissions)
|
case 'admin.report':
|
||||||
)
|
return (
|
||||||
}
|
featureCheck('notification_type_admin_report') && checkPermission(permission, permissions)
|
||||||
}) as { type: 'admin.sign_up' | 'admin.report'; permission: number }[]
|
)
|
||||||
|
}
|
||||||
|
}) as { type: 'admin.sign_up' | 'admin.report'; permission: number }[]
|
||||||
|
|
||||||
export const setChannels = async (reset: boolean | undefined = false, specificAccount?: string) => {
|
export const setChannels = async (reset: boolean | undefined = false, specificAccount?: string) => {
|
||||||
const account = specificAccount || getGlobalStorage.string('account.active')
|
const account = specificAccount || getGlobalStorage.string('account.active')
|
||||||
|
@ -76,18 +72,18 @@ export const setChannels = async (reset: boolean | undefined = false, specificAc
|
||||||
|
|
||||||
if (!accountDetails.push.decode) {
|
if (!accountDetails.push.decode) {
|
||||||
await setChannel('default')
|
await setChannel('default')
|
||||||
for (const push of PUSH_DEFAULT) {
|
for (const push of PUSH_DEFAULT()) {
|
||||||
await deleteChannel(push)
|
await deleteChannel(push)
|
||||||
}
|
}
|
||||||
for (const { type } of PUSH_ADMIN) {
|
for (const { type } of PUSH_ADMIN()) {
|
||||||
await deleteChannel(type)
|
await deleteChannel(type)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await deleteChannel('default')
|
await deleteChannel('default')
|
||||||
for (const push of PUSH_DEFAULT) {
|
for (const push of PUSH_DEFAULT()) {
|
||||||
await setChannel(push)
|
await setChannel(push)
|
||||||
}
|
}
|
||||||
for (const { type } of PUSH_ADMIN) {
|
for (const { type } of PUSH_ADMIN()) {
|
||||||
await setChannel(type)
|
await setChannel(type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,11 @@ const useProfileQuery = (
|
||||||
options: UseQueryOptions<AccountWithSource, AxiosError>
|
options: UseQueryOptions<AccountWithSource, AxiosError>
|
||||||
} | void
|
} | void
|
||||||
) => {
|
) => {
|
||||||
return useQuery(queryKey, queryFunctionProfile, params?.options)
|
return useQuery(queryKey, queryFunctionProfile, {
|
||||||
|
...params?.options,
|
||||||
|
staleTime: Infinity,
|
||||||
|
cacheTime: Infinity
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type MutationVarsProfileBase =
|
type MutationVarsProfileBase =
|
||||||
|
|
Loading…
Reference in New Issue