Skip to content

Commit

Permalink
Initial mark as done
Browse files Browse the repository at this point in the history
  • Loading branch information
iower committed Dec 14, 2023
1 parent 8b56968 commit 4521aeb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/left/UluInboxChats.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from '../../lib/teact/teact';
import React, { memo } from '../../lib/teact/teact';
import React, { memo, useEffect } from '../../lib/teact/teact';

import type { GlobalState } from '../../global/types';
import type { FolderEditDispatch } from '../../hooks/reducers/useFoldersReducer';
Expand All @@ -9,10 +9,12 @@ import { ANIMATION_END_DELAY, IS_STORIES_ENABLED } from '../../config';
import buildClassName from '../../util/buildClassName';
import { ANIMATION_DURATION } from '../story/helpers/ribbonAnimation';

import useDone from '../../hooks/useDone';
import useForumPanelRender from '../../hooks/useForumPanelRender';
import useHistoryBack from '../../hooks/useHistoryBack';
import useLang from '../../hooks/useLang';
import useShowTransition from '../../hooks/useShowTransition';
import { useStorage } from '../../hooks/useStorage';
import useLeftHeaderButtonRtlForumTransition from './main/hooks/useLeftHeaderButtonRtlForumTransition';

import StoryRibbon from '../story/StoryRibbon';
Expand Down Expand Up @@ -48,6 +50,15 @@ const UluInboxChats: FC<OwnProps> = ({
}) => {
const lang = useLang();

const { doneAllReadChats } = useDone();
const { isInitialMarkAsDone, setIsInitialMarkAsDone } = useStorage();
useEffect(() => {
if (!isInitialMarkAsDone) {
setIsInitialMarkAsDone(true);
doneAllReadChats();
}
}, [isInitialMarkAsDone, setIsInitialMarkAsDone, doneAllReadChats]);

useHistoryBack({
isActive,
onBack: onReset,
Expand Down
7 changes: 7 additions & 0 deletions src/hooks/useStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export function useStorage() {

const [doneChatIds, setDoneChatIds] = useLocalStorage<string[]>('ulu_done_chat_ids', []);

const [
isInitialMarkAsDone,
setIsInitialMarkAsDone,
] = useLocalStorage<boolean>('ulu_is_initial_mark_as_done', false);

return {
isAutoDoneEnabled,
setIsAutoDoneEnabled,
Expand All @@ -28,6 +33,8 @@ export function useStorage() {
setIsFoldersTreeEnabled,
doneChatIds,
setDoneChatIds,
isInitialMarkAsDone,
setIsInitialMarkAsDone,
};
}

Expand Down

0 comments on commit 4521aeb

Please sign in to comment.