Skip to content

Commit

Permalink
Merge pull request #4 from wpdas/staging
Browse files Browse the repository at this point in the history
clean up chat list if user is signed out
  • Loading branch information
wpdas committed Apr 9, 2024
2 parents ed9d7d9 + ef2f4d9 commit 173887e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ModulesProvider, RouterContext, loadExternalStyles } from "alem";
import { ModulesProvider, RouterContext, context, loadExternalStyles, useEffect } from "alem";
import Main from "./Main";
import Spinner from "./components/Spinner/Spinner";
import cleanUpChatList from "./services/cleanUpChatList";

const App = () => {
const ready = loadExternalStyles([
Expand All @@ -9,6 +10,14 @@ const App = () => {

RouterContext();

useEffect(() => {
// clean up storage
if (!context.accountId) {
console.log("Shoud i go?");
cleanUpChatList();
}
}, [context.accountId]);

return (
<div className="App">
<ModulesProvider />
Expand Down
2 changes: 1 addition & 1 deletion src/screens/ChatsList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ChatsList = () => {

return (
<div className="contacts-list">
{!chats.length ? (
{chats.length === 0 ? (
<CenterMessage message="No chat has started yet" />
) : (
<ContactItems accountIds={chats} onSelect={onSelect} />
Expand Down
6 changes: 6 additions & 0 deletions src/services/cleanUpChatList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CHAT_LIST_KEY } from "@app/constants";
import { Storage } from "alem";

const cleanUpChatList = () => Storage.set(CHAT_LIST_KEY, []);

export default cleanUpChatList;

0 comments on commit 173887e

Please sign in to comment.