[Glitch] Remember revealed archetype on future Wrapstodon visits

Port b72b507584 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
diondiondion
2025-12-12 12:03:00 +01:00
committed by Claire
parent 8fad8681ab
commit acf583d374
3 changed files with 15 additions and 3 deletions

View File

@@ -6,11 +6,13 @@ import classNames from 'classnames';
import { Avatar } from '@/flavours/glitch/components/avatar';
import { Button } from '@/flavours/glitch/components/button';
import { me } from '@/flavours/glitch/initial_state';
import type { Account } from '@/flavours/glitch/models/account';
import type {
AnnualReport,
Archetype as ArchetypeData,
} from '@/flavours/glitch/models/annual_report';
import { wrapstodonSettings } from '@/flavours/glitch/settings';
import booster from '@/images/archetypes/booster.png';
import lurker from '@/images/archetypes/lurker.png';
import oracle from '@/images/archetypes/oracle.png';
@@ -117,9 +119,16 @@ export const Archetype: React.FC<{
const wrapperRef = useRef<HTMLDivElement>(null);
const isSelfView = context === 'modal';
const [isRevealed, setIsRevealed] = useState(!isSelfView);
const [isRevealed, setIsRevealed] = useState(
() =>
!isSelfView ||
(me ? (wrapstodonSettings.get(me)?.archetypeRevealed ?? false) : true),
);
const reveal = useCallback(() => {
setIsRevealed(true);
if (me) {
wrapstodonSettings.set(me, { archetypeRevealed: true });
}
wrapperRef.current?.focus();
}, []);

View File

@@ -139,8 +139,8 @@ const persistVolume = (volume: number, muted: boolean) => {
};
const restoreVolume = (video: HTMLVideoElement) => {
const volume = (playerSettings.get('volume') as number | undefined) ?? 0.5;
const muted = (playerSettings.get('muted') as boolean | undefined) ?? false;
const volume = playerSettings.get('volume') ?? 0.5;
const muted = playerSettings.get('muted') ?? false;
video.volume = volume;
video.muted = muted;

View File

@@ -63,3 +63,6 @@ export const searchHistory = new Settings<Record<string, RecentSearch[]>>(
export const playerSettings = new Settings<{ volume: number; muted: boolean }>(
'mastodon_player',
);
export const wrapstodonSettings = new Settings<
Record<string, { archetypeRevealed: boolean }>
>('wrapstodon');