mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-26 20:36:25 +00:00
[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:
@@ -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();
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user