Skip to content

Commit

Permalink
update useeffect
Browse files Browse the repository at this point in the history
  • Loading branch information
corlard3y committed Jul 22, 2024
1 parent e76f281 commit 5bd4af2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export default function App() {

const { pgpPvtKey } = useContext<any>(AppContext);
const { sidebarCollapsed, setSidebarCollapsed } = useContext(GlobalContext);
const mounted = useRef<any>();

const updateOnboardTheme = useUpdateTheme();
const { userPushSDKInstance } = useSelector((state: any) => {
Expand All @@ -218,20 +219,21 @@ export default function App() {
setcurrentTime(now);
}, []);

const mounted = useRef<any>();
const resetState = () => {
dispatch(resetSpamSlice());
dispatch(resetNotificationsSlice());
dispatch(resetCanSendSlice());
dispatch(resetChannelCreationSlice());
dispatch(resetAdminSlice());
dispatch(resetUserSlice());
};

useEffect(() => {
if (!mounted.current) {
// do componentDidMount logic
mounted.current = true;

if (!account) return;
dispatch(resetSpamSlice());
dispatch(resetNotificationsSlice());
dispatch(resetCanSendSlice());
dispatch(resetChannelCreationSlice());
dispatch(resetAdminSlice());
dispatch(resetUserSlice());
resetState();
}
}, [account]);

Expand Down Expand Up @@ -348,7 +350,7 @@ export default function App() {
<ChatUIProvider
user={userPushSDKInstance}
theme={darkMode && darkChatTheme}
debug={true}
debug={false}
uiConfig={{
suppressToast: false,
}}
Expand Down

0 comments on commit 5bd4af2

Please sign in to comment.