Fix CI lint errors
This commit is contained in:
parent
42e5a2431c
commit
fe43676c32
3 changed files with 22 additions and 21 deletions
|
|
@ -41,8 +41,14 @@ const MessageRowWithObserver = ({
|
||||||
const reportedRef = useRef(false);
|
const reportedRef = useRef(false);
|
||||||
const messageRef = useRef(message);
|
const messageRef = useRef(message);
|
||||||
const onVisibleRef = useRef(onVisible);
|
const onVisibleRef = useRef(onVisible);
|
||||||
messageRef.current = message;
|
|
||||||
onVisibleRef.current = onVisible;
|
useEffect(() => {
|
||||||
|
messageRef.current = message;
|
||||||
|
}, [message]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onVisibleRef.current = onVisible;
|
||||||
|
}, [onVisible]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!onVisible) return;
|
if (!onVisible) return;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ export const TaskDetailDialog = ({
|
||||||
if (comments.length === 0) return;
|
if (comments.length === 0) return;
|
||||||
const latest = Math.max(...comments.map((c) => new Date(c.createdAt).getTime()));
|
const latest = Math.max(...comments.map((c) => new Date(c.createdAt).getTime()));
|
||||||
if (latest > 0) markAsRead(teamName, currentTask.id, latest);
|
if (latest > 0) markAsRead(teamName, currentTask.id, latest);
|
||||||
}, [open, teamName, currentTask?.id, currentTask?.comments]);
|
}, [open, teamName, currentTask]);
|
||||||
|
|
||||||
const handleDependencyClick = (taskId: string): void => {
|
const handleDependencyClick = (taskId: string): void => {
|
||||||
onClose();
|
onClose();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getReadSet as getReadSetStorage,
|
getReadSet as getReadSetStorage,
|
||||||
|
|
@ -9,28 +9,23 @@ export function useTeamMessagesRead(teamName: string): {
|
||||||
readSet: Set<string>;
|
readSet: Set<string>;
|
||||||
markRead: (messageKey: string) => void;
|
markRead: (messageKey: string) => void;
|
||||||
} {
|
} {
|
||||||
const [readSet, setReadSet] = useState<Set<string>>(() =>
|
const [version, setVersion] = useState(0);
|
||||||
teamName ? getReadSetStorage(teamName) : new Set()
|
const readSet = useMemo(
|
||||||
|
() => {
|
||||||
|
if (version < 0) return new Set<string>();
|
||||||
|
return teamName ? getReadSetStorage(teamName) : new Set();
|
||||||
|
},
|
||||||
|
[teamName, version]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!teamName) {
|
|
||||||
setReadSet(new Set());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setReadSet(getReadSetStorage(teamName));
|
|
||||||
}, [teamName]);
|
|
||||||
|
|
||||||
const markRead = useCallback(
|
const markRead = useCallback(
|
||||||
(messageKey: string) => {
|
(messageKey: string) => {
|
||||||
if (!teamName) return;
|
if (!teamName) return;
|
||||||
setReadSet((prev) => {
|
const existing = getReadSetStorage(teamName);
|
||||||
if (prev.has(messageKey)) return prev;
|
if (existing.has(messageKey)) return;
|
||||||
const next = new Set(prev);
|
existing.add(messageKey);
|
||||||
next.add(messageKey);
|
markReadStorage(teamName, messageKey, existing);
|
||||||
markReadStorage(teamName, messageKey, next);
|
setVersion((v) => v + 1);
|
||||||
return next;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
[teamName]
|
[teamName]
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue