Clear announcement history using window.clearLastViewedAnnouncement()

This helps testing, and can be eventually removed. No harm leaving it there, though.
This commit is contained in:
infinite-persistence 2022-05-18 17:19:51 +08:00
parent d70f0f1d6d
commit 14a11aa78a
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 11 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import {
selectSyncIsLocked, selectSyncIsLocked,
} from 'redux/selectors/sync'; } from 'redux/selectors/sync';
import { doUserSetReferrer } from 'redux/actions/user'; import { doUserSetReferrer } from 'redux/actions/user';
import { doSetLastViewedAnnouncement } from 'redux/actions/content';
import { import {
selectOdyseeMembershipIsPremiumPlus, selectOdyseeMembershipIsPremiumPlus,
selectUser, selectUser,
@ -58,6 +59,7 @@ const perform = {
fetchModBlockedList: doFetchModBlockedList, fetchModBlockedList: doFetchModBlockedList,
fetchModAmIList: doFetchCommentModAmIList, fetchModAmIList: doFetchCommentModAmIList,
doOpenAnnouncements, doOpenAnnouncements,
doSetLastViewedAnnouncement,
}; };
export default hot(connect(select, perform)(App)); export default hot(connect(select, perform)(App));

View file

@ -89,6 +89,7 @@ type Props = {
fetchModAmIList: () => void, fetchModAmIList: () => void,
homepageFetched: boolean, homepageFetched: boolean,
doOpenAnnouncements: () => void, doOpenAnnouncements: () => void,
doSetLastViewedAnnouncement: (hash: string) => void,
}; };
function App(props: Props) { function App(props: Props) {
@ -123,6 +124,7 @@ function App(props: Props) {
fetchModAmIList, fetchModAmIList,
homepageFetched, homepageFetched,
doOpenAnnouncements, doOpenAnnouncements,
doSetLastViewedAnnouncement,
} = props; } = props;
const isMobile = useIsMobile(); const isMobile = useIsMobile();
@ -481,6 +483,13 @@ function App(props: Props) {
} }
}, [prefsReady]); }, [prefsReady]);
useEffect(() => {
window.clearLastViewedAnnouncement = () => {
console.log('Clearing history. Please wait ...');
doSetLastViewedAnnouncement('');
};
}, []);
// Keep this at the end to ensure initial setup effects are run first // Keep this at the end to ensure initial setup effects are run first
useEffect(() => { useEffect(() => {
if (!hasSignedIn && hasVerifiedEmail) { if (!hasSignedIn && hasVerifiedEmail) {