[Glitch] Remember revealed archetype on future Wrapstodon visits
Port b72b5075848e65cb7eebb5e64ece59ed0e77be57 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
8fad8681ab
commit
acf583d374
@ -6,11 +6,13 @@ import classNames from 'classnames';
|
|||||||
|
|
||||||
import { Avatar } from '@/flavours/glitch/components/avatar';
|
import { Avatar } from '@/flavours/glitch/components/avatar';
|
||||||
import { Button } from '@/flavours/glitch/components/button';
|
import { Button } from '@/flavours/glitch/components/button';
|
||||||
|
import { me } from '@/flavours/glitch/initial_state';
|
||||||
import type { Account } from '@/flavours/glitch/models/account';
|
import type { Account } from '@/flavours/glitch/models/account';
|
||||||
import type {
|
import type {
|
||||||
AnnualReport,
|
AnnualReport,
|
||||||
Archetype as ArchetypeData,
|
Archetype as ArchetypeData,
|
||||||
} from '@/flavours/glitch/models/annual_report';
|
} from '@/flavours/glitch/models/annual_report';
|
||||||
|
import { wrapstodonSettings } from '@/flavours/glitch/settings';
|
||||||
import booster from '@/images/archetypes/booster.png';
|
import booster from '@/images/archetypes/booster.png';
|
||||||
import lurker from '@/images/archetypes/lurker.png';
|
import lurker from '@/images/archetypes/lurker.png';
|
||||||
import oracle from '@/images/archetypes/oracle.png';
|
import oracle from '@/images/archetypes/oracle.png';
|
||||||
@ -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');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user