feat: add anonymous mode toggle to hide reading progress and tracking
Adds a toggleable anonymous mode (eye icon in header) that: - Stops syncing read progress to the server while reading - Hides mark as read/unread buttons on book covers and lists - Hides reading status badges on series and books - Hides progress bars on series and book covers - Hides "continue reading" and "continue series" sections on home - Persists the setting server-side in user preferences (anonymousMode) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
34
src/contexts/AnonymousContext.tsx
Normal file
34
src/contexts/AnonymousContext.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
"use client";
|
||||
|
||||
import React, { createContext, useContext, useMemo, useCallback } from "react";
|
||||
import { usePreferences } from "@/contexts/PreferencesContext";
|
||||
|
||||
interface AnonymousContextType {
|
||||
isAnonymous: boolean;
|
||||
toggleAnonymous: () => void;
|
||||
}
|
||||
|
||||
const AnonymousContext = createContext<AnonymousContextType | undefined>(undefined);
|
||||
|
||||
export function AnonymousProvider({ children }: { children: React.ReactNode }) {
|
||||
const { preferences, updatePreferences } = usePreferences();
|
||||
|
||||
const toggleAnonymous = useCallback(() => {
|
||||
updatePreferences({ anonymousMode: !preferences.anonymousMode });
|
||||
}, [preferences.anonymousMode, updatePreferences]);
|
||||
|
||||
const contextValue = useMemo(
|
||||
() => ({ isAnonymous: preferences.anonymousMode, toggleAnonymous }),
|
||||
[preferences.anonymousMode, toggleAnonymous]
|
||||
);
|
||||
|
||||
return <AnonymousContext.Provider value={contextValue}>{children}</AnonymousContext.Provider>;
|
||||
}
|
||||
|
||||
export function useAnonymous() {
|
||||
const context = useContext(AnonymousContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("useAnonymous must be used within an AnonymousProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in New Issue
Block a user