MCPcopy
hub / github.com/fccview/jotty / KonamiProvider

Function KonamiProvider

app/_providers/KonamiProvider.tsx:32–78  ·  view source on GitHub ↗
({ children }: { children: React.ReactNode })

Source from the content-addressed store, hash-verified

30};
31
32export function KonamiProvider({ children }: { children: React.ReactNode }) {
33 const content = useRef<Map<Text, string>>(new Map());
34 const { setUser } = useAppMode();
35 const router = useRouter();
36 const routerRef = useRef(router);
37
38 useEffect(() => {
39 routerRef.current = router;
40 }, [router]);
41
42 const handleSpecialTranslation = useCallback(
43 (translation: string) => {
44 updateUserSettings({ preferredLocale: translation }).then((result) => {
45 if (result.success && result.data?.user) {
46 setUser(result.data.user);
47 routerRef.current.refresh();
48 }
49 });
50 },
51 [setUser]
52 );
53
54 const { isChaos, toggleChaos, activeGif, clearGif } = useEasterEggs({
55 onSpecialTranslation: handleSpecialTranslation,
56 });
57
58 const apply = useCallback(
59 () => startChaos(getTextNodes(document.body), content.current),
60 []
61 );
62
63 const reset = useCallback(() => {
64 resetChaos(content.current);
65 }, []);
66
67 useEffect(() => {
68 if (!isChaos) return reset();
69 apply();
70 }, [isChaos, apply, reset]);
71
72 return (
73 <ChaosContext.Provider value={{ isChaos, toggleChaos }}>
74 {children}
75 <ImageOverlay src={activeGif} onClose={clearGif} alt="Easter egg" />
76 </ChaosContext.Provider>
77 );
78}

Callers

nothing calls this directly

Calls 6

useAppModeFunction · 0.90
updateUserSettingsFunction · 0.90
useEasterEggsFunction · 0.90
startChaosFunction · 0.90
getTextNodesFunction · 0.90
resetChaosFunction · 0.90

Tested by

no test coverage detected