kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Let nip05 notification be dismissed
rodzic
0b9fe49cbf
commit
b98f39753d
|
@ -5,6 +5,7 @@ import { Stack } from 'soapbox/components/ui';
|
||||||
import { useStatContext } from 'soapbox/contexts/stat-context';
|
import { useStatContext } from 'soapbox/contexts/stat-context';
|
||||||
import ComposeButton from 'soapbox/features/ui/components/compose-button';
|
import ComposeButton from 'soapbox/features/ui/components/compose-button';
|
||||||
import { useAppSelector, useFeatures, useOwnAccount, useSettings, useInstance } from 'soapbox/hooks';
|
import { useAppSelector, useFeatures, useOwnAccount, useSettings, useInstance } from 'soapbox/hooks';
|
||||||
|
import { useSettingsNotifications } from 'soapbox/hooks/useSettingsNotifications';
|
||||||
|
|
||||||
import DropdownMenu, { Menu } from './dropdown-menu';
|
import DropdownMenu, { Menu } from './dropdown-menu';
|
||||||
import SidebarNavigationLink from './sidebar-navigation-link';
|
import SidebarNavigationLink from './sidebar-navigation-link';
|
||||||
|
@ -30,6 +31,7 @@ const SidebarNavigation = () => {
|
||||||
const notificationCount = useAppSelector((state) => state.notifications.unread);
|
const notificationCount = useAppSelector((state) => state.notifications.unread);
|
||||||
const followRequestsCount = useAppSelector((state) => state.user_lists.follow_requests.items.count());
|
const followRequestsCount = useAppSelector((state) => state.user_lists.follow_requests.items.count());
|
||||||
const dashboardCount = useAppSelector((state) => state.admin.openReports.count() + state.admin.awaitingApproval.count());
|
const dashboardCount = useAppSelector((state) => state.admin.openReports.count() + state.admin.awaitingApproval.count());
|
||||||
|
const settingsNotifications = useSettingsNotifications();
|
||||||
|
|
||||||
const restrictUnauth = instance.pleroma.metadata.restrict_unauthenticated;
|
const restrictUnauth = instance.pleroma.metadata.restrict_unauthenticated;
|
||||||
|
|
||||||
|
@ -160,7 +162,7 @@ const SidebarNavigation = () => {
|
||||||
icon={require('@tabler/icons/outline/settings.svg')}
|
icon={require('@tabler/icons/outline/settings.svg')}
|
||||||
activeIcon={require('@tabler/icons/filled/settings.svg')}
|
activeIcon={require('@tabler/icons/filled/settings.svg')}
|
||||||
text={<FormattedMessage id='tabs_bar.settings' defaultMessage='Settings' />}
|
text={<FormattedMessage id='tabs_bar.settings' defaultMessage='Settings' />}
|
||||||
count={features.nip05 && account.acct !== account.source?.nostr?.nip05 ? 1 : 0}
|
count={settingsNotifications.size}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{account.staff && (
|
{account.staff && (
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||||
import React, { useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { patchMe } from 'soapbox/actions/me';
|
import { patchMe } from 'soapbox/actions/me';
|
||||||
|
import { changeSetting } from 'soapbox/actions/settings';
|
||||||
import List, { ListItem } from 'soapbox/components/list';
|
import List, { ListItem } from 'soapbox/components/list';
|
||||||
import { Button, CardHeader, CardTitle, Column, Emoji, Form, HStack, Icon, Input, Textarea, Tooltip } from 'soapbox/components/ui';
|
import { Button, CardHeader, CardTitle, Column, Emoji, Form, HStack, Icon, Input, Textarea, Tooltip } from 'soapbox/components/ui';
|
||||||
import { useApi, useAppDispatch, useInstance, useOwnAccount } from 'soapbox/hooks';
|
import { useApi, useAppDispatch, useInstance, useOwnAccount, useSettings } from 'soapbox/hooks';
|
||||||
import { queryClient } from 'soapbox/queries/client';
|
import { queryClient } from 'soapbox/queries/client';
|
||||||
import { adminAccountSchema } from 'soapbox/schemas/admin-account';
|
import { adminAccountSchema } from 'soapbox/schemas/admin-account';
|
||||||
import toast from 'soapbox/toast';
|
import toast from 'soapbox/toast';
|
||||||
|
@ -33,10 +34,20 @@ const EditIdentity: React.FC<IEditIdentity> = () => {
|
||||||
|
|
||||||
const { data: approvedNames } = useNames();
|
const { data: approvedNames } = useNames();
|
||||||
const { data: pendingNames } = usePendingNames();
|
const { data: pendingNames } = usePendingNames();
|
||||||
|
const { dismissedSettingsNotifications } = useSettings();
|
||||||
|
|
||||||
const [username, setUsername] = useState<string>('');
|
const [username, setUsername] = useState<string>('');
|
||||||
const [reason, setReason] = useState<string>('');
|
const [reason, setReason] = useState<string>('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const dismissed = new Set(dismissedSettingsNotifications);
|
||||||
|
|
||||||
|
if (!dismissed.has('needsNip05')) {
|
||||||
|
dismissed.add('needsNip05');
|
||||||
|
dispatch(changeSetting(['dismissedSettingsNotifications'], [...dismissed]));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (!account) return null;
|
if (!account) return null;
|
||||||
|
|
||||||
const updateName = async (name: string): Promise<void> => {
|
const updateName = async (name: string): Promise<void> => {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import CopyableInput from 'soapbox/components/copyable-input';
|
||||||
import List, { ListItem } from 'soapbox/components/list';
|
import List, { ListItem } from 'soapbox/components/list';
|
||||||
import { Card, CardBody, CardHeader, CardTitle, Column, Counter, FormGroup, Text } from 'soapbox/components/ui';
|
import { Card, CardBody, CardHeader, CardTitle, Column, Counter, FormGroup, Text } from 'soapbox/components/ui';
|
||||||
import { useAppDispatch, useAppSelector, useFeatures, useInstance, useOwnAccount } from 'soapbox/hooks';
|
import { useAppDispatch, useAppSelector, useFeatures, useInstance, useOwnAccount } from 'soapbox/hooks';
|
||||||
|
import { useSettingsNotifications } from 'soapbox/hooks/useSettingsNotifications';
|
||||||
|
|
||||||
import Preferences from '../preferences';
|
import Preferences from '../preferences';
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ const Settings = () => {
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const { account } = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
|
const settingsNotifications = useSettingsNotifications();
|
||||||
|
|
||||||
const isMfaEnabled = mfa.getIn(['settings', 'totp']);
|
const isMfaEnabled = mfa.getIn(['settings', 'totp']);
|
||||||
|
|
||||||
|
@ -73,7 +75,7 @@ const Settings = () => {
|
||||||
<ListItem label={intl.formatMessage(messages.editIdentity)} to='/settings/identity'>
|
<ListItem label={intl.formatMessage(messages.editIdentity)} to='/settings/identity'>
|
||||||
<span className='max-w-full truncate'>
|
<span className='max-w-full truncate'>
|
||||||
{account?.source?.nostr?.nip05}
|
{account?.source?.nostr?.nip05}
|
||||||
{features.nip05 && <Counter count={1} />}
|
{settingsNotifications.has('needsNip05') && <Counter count={1} />}
|
||||||
</span>
|
</span>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { useFeatures } from './useFeatures';
|
||||||
|
import { useOwnAccount } from './useOwnAccount';
|
||||||
|
import { useSettings } from './useSettings';
|
||||||
|
|
||||||
|
type SettingsNotification = 'needsNip05';
|
||||||
|
|
||||||
|
/** Get a list of notifications for settings. */
|
||||||
|
export function useSettingsNotifications(): Set<SettingsNotification> {
|
||||||
|
const notifications: Set<SettingsNotification> = new Set();
|
||||||
|
|
||||||
|
const features = useFeatures();
|
||||||
|
const { account } = useOwnAccount();
|
||||||
|
const { dismissedSettingsNotifications } = useSettings();
|
||||||
|
|
||||||
|
if (
|
||||||
|
!dismissedSettingsNotifications.includes('needsNip05')
|
||||||
|
&& account
|
||||||
|
&& features.nip05
|
||||||
|
&& account.acct !== account.source?.nostr?.nip05
|
||||||
|
) {
|
||||||
|
notifications.add('needsNip05');
|
||||||
|
}
|
||||||
|
|
||||||
|
return notifications;
|
||||||
|
}
|
|
@ -73,6 +73,8 @@ const settingsSchema = z.object({
|
||||||
show: z.boolean().catch(true),
|
show: z.boolean().catch(true),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
/** Settings notifications that have been dismissed. See `useSettingsNotifications` hook. */
|
||||||
|
dismissedSettingsNotifications: z.array(z.string()).catch([]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Settings = z.infer<typeof settingsSchema>;
|
type Settings = z.infer<typeof settingsSchema>;
|
||||||
|
|
Ładowanie…
Reference in New Issue