mirror of https://github.com/usememos/memos
refactor: simplify NSFW implementation by inlining logic
- Remove unused showNsfwContent prop (was only used in MemoDetail to pre-reveal NSFW, which defeats the purpose) - Inline useNsfwContent hook logic directly into MemoView.tsx (only 3 lines, no reusability benefit) - Delete web/src/components/MemoView/hooks/useNsfwContent.ts - NSFW content now consistently starts hidden across all pages - Maintains same user experience: click to reveal, no toggle back This removes unnecessary indirection and prop threading while preserving functionality.pull/5573/head
parent
6db58fae11
commit
29412f4690
@ -1,21 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import type { Memo } from "@/types/proto/api/v1/memo_service_pb";
|
||||
|
||||
export interface UseNsfwContentReturn {
|
||||
nsfw: boolean;
|
||||
showNSFWContent: boolean;
|
||||
toggleNsfwVisibility: () => void;
|
||||
}
|
||||
|
||||
export const useNsfwContent = (memo: Memo, initialShowNsfw?: boolean): UseNsfwContentReturn => {
|
||||
const [showNSFWContent, setShowNSFWContent] = useState(initialShowNsfw ?? false);
|
||||
|
||||
// Always blur content tagged with NSFW
|
||||
const nsfw = memo.tags?.includes("NSFW") ?? false;
|
||||
|
||||
return {
|
||||
nsfw,
|
||||
showNSFWContent,
|
||||
toggleNsfwVisibility: () => setShowNSFWContent((prev) => !prev),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue