mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
Remember revealed archetype on future Wrapstodon visits (#37219)
This commit is contained in:
@@ -12,11 +12,13 @@ import replier from '@/images/archetypes/replier.png';
|
|||||||
import space_elements from '@/images/archetypes/space_elements.png';
|
import space_elements from '@/images/archetypes/space_elements.png';
|
||||||
import { Avatar } from '@/mastodon/components/avatar';
|
import { Avatar } from '@/mastodon/components/avatar';
|
||||||
import { Button } from '@/mastodon/components/button';
|
import { Button } from '@/mastodon/components/button';
|
||||||
|
import { me } from '@/mastodon/initial_state';
|
||||||
import type { Account } from '@/mastodon/models/account';
|
import type { Account } from '@/mastodon/models/account';
|
||||||
import type {
|
import type {
|
||||||
AnnualReport,
|
AnnualReport,
|
||||||
Archetype as ArchetypeData,
|
Archetype as ArchetypeData,
|
||||||
} from '@/mastodon/models/annual_report';
|
} from '@/mastodon/models/annual_report';
|
||||||
|
import { wrapstodonSettings } from '@/mastodon/settings';
|
||||||
|
|
||||||
import styles from './index.module.scss';
|
import styles from './index.module.scss';
|
||||||
import { ShareButton } from './share_button';
|
import { ShareButton } from './share_button';
|
||||||
@@ -117,9 +119,16 @@ export const Archetype: React.FC<{
|
|||||||
const wrapperRef = useRef<HTMLDivElement>(null);
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
||||||
const isSelfView = context === 'modal';
|
const isSelfView = context === 'modal';
|
||||||
|
|
||||||
const [isRevealed, setIsRevealed] = useState(!isSelfView);
|
const [isRevealed, setIsRevealed] = useState(
|
||||||
|
() =>
|
||||||
|
!isSelfView ||
|
||||||
|
(me ? (wrapstodonSettings.get(me)?.archetypeRevealed ?? false) : true),
|
||||||
|
);
|
||||||
const reveal = useCallback(() => {
|
const reveal = useCallback(() => {
|
||||||
setIsRevealed(true);
|
setIsRevealed(true);
|
||||||
|
if (me) {
|
||||||
|
wrapstodonSettings.set(me, { archetypeRevealed: true });
|
||||||
|
}
|
||||||
wrapperRef.current?.focus();
|
wrapperRef.current?.focus();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ const persistVolume = (volume: number, muted: boolean) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const restoreVolume = (video: HTMLVideoElement) => {
|
const restoreVolume = (video: HTMLVideoElement) => {
|
||||||
const volume = (playerSettings.get('volume') as number | undefined) ?? 0.5;
|
const volume = playerSettings.get('volume') ?? 0.5;
|
||||||
const muted = (playerSettings.get('muted') as boolean | undefined) ?? false;
|
const muted = playerSettings.get('muted') ?? false;
|
||||||
|
|
||||||
video.volume = volume;
|
video.volume = volume;
|
||||||
video.muted = muted;
|
video.muted = muted;
|
||||||
|
|||||||
@@ -63,3 +63,6 @@ export const searchHistory = new Settings<Record<string, RecentSearch[]>>(
|
|||||||
export const playerSettings = new Settings<{ volume: number; muted: boolean }>(
|
export const playerSettings = new Settings<{ volume: number; muted: boolean }>(
|
||||||
'mastodon_player',
|
'mastodon_player',
|
||||||
);
|
);
|
||||||
|
export const wrapstodonSettings = new Settings<
|
||||||
|
Record<string, { archetypeRevealed: boolean }>
|
||||||
|
>('wrapstodon');
|
||||||
|
|||||||
Reference in New Issue
Block a user