Skip to content

Commit

Permalink
fix: chat dialog and notification dot (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
imvinay84 authored Mar 23, 2023
1 parent 797016e commit a3d576c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
1 change: 0 additions & 1 deletion packages/extension/src/pages/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ const ChatView = () => {
if (
!userState?.messagingPubKey.publicKey &&
!userState?.messagingPubKey.privacySetting &&
!userState?.accessToken.length &&
!loadingChats &&
!authFail
) {
Expand Down
6 changes: 2 additions & 4 deletions packages/extension/src/pages/setting/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ export const ChatSettings: FunctionComponent = observer(() => {
fetchBlockList();
setLoadingChatSettings(false);
};
if (
(!userState.accessToken.length || !userState.messagingPubKey.length) &&
!loadingChatSettings
)

if (!userState.messagingPubKey.length && !loadingChatSettings)
setJWTAndFetchMsgPubKey();
}, [current.chainId, walletAddress]);

Expand Down
39 changes: 22 additions & 17 deletions packages/extension/src/pages/setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import style from "./style.module.scss";
import { useLanguage } from "../../languages";
import { useIntl } from "react-intl";
import { observer } from "mobx-react-lite";
import { userDetails } from "@chatStore/user-slice";
import {
userChatActive,
WalletConfig,
Expand All @@ -25,6 +26,7 @@ export const SettingPage: FunctionComponent = observer(() => {
const current = chainStore.current;
const accountInfo = accountStore.getAccount(current.chainId);
const config: WalletConfig = useSelector(walletConfig);
const userState = useSelector(userDetails);
const paragraphLang = language.automatic
? intl.formatMessage(
{
Expand Down Expand Up @@ -111,23 +113,26 @@ export const SettingPage: FunctionComponent = observer(() => {
[]
)}
/>
<PageButton
style={{ cursor: isChatActive ? "pointer" : "not-allowed" }}
paragraph={
isChatActive ? "" : "You need FET balance to use this feature"
}
title={"Chat"}
onClick={() => {
if (isChatActive)
history.push({
pathname: "/setting/chat",
});
}}
icons={useMemo(
() => [<i key="next" className="fas fa-chevron-right" />],
[]
)}
/>
{(userState.messagingPubKey?.publicKey?.length ||
userState.messagingPubKey?.privacySetting?.length) && (
<PageButton
style={{ cursor: isChatActive ? "pointer" : "not-allowed" }}
paragraph={
isChatActive ? "" : "You need FET balance to use this feature"
}
title={"Chat"}
onClick={() => {
if (isChatActive)
history.push({
pathname: "/setting/chat",
});
}}
icons={useMemo(
() => [<i key="next" className="fas fa-chevron-right" />],
[]
)}
/>
)}
{config.notiphyWhitelist !== undefined &&
config.notiphyWhitelist.length !== 0 &&
config.notiphyWhitelist.indexOf(accountInfo.bech32Address) !== -1 && (
Expand Down
5 changes: 4 additions & 1 deletion packages/extension/src/utils/populate-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export const fetchAndPopulateNotifications = async (walletAddress: string) => {
);

store.dispatch(
setNotifications({ allNotifications: Object.values(notifications) })
setNotifications({
unreadNotification: Object.values(notifications).length > 0,
allNotifications: Object.values(notifications),
})
);
};

0 comments on commit a3d576c

Please sign in to comment.