minor updates
This commit is contained in:
@@ -2,7 +2,7 @@ import { Image } from "@shared/image";
|
||||
import { RelayContext } from "@shared/relayProvider";
|
||||
import { useActiveAccount } from "@stores/accounts";
|
||||
import { useChannels } from "@stores/channels";
|
||||
import { useChats } from "@stores/chats";
|
||||
import { useChatMessages, useChats } from "@stores/chats";
|
||||
import { DEFAULT_AVATAR, READONLY_RELAYS } from "@stores/constants";
|
||||
import { usePageContext } from "@utils/hooks/usePageContext";
|
||||
import { useProfile } from "@utils/hooks/useProfile";
|
||||
@@ -13,26 +13,27 @@ import useSWRSubscription from "swr/subscription";
|
||||
export function ActiveAccount({ data }: { data: any }) {
|
||||
const pool: any = useContext(RelayContext);
|
||||
const pageContext = usePageContext();
|
||||
const pathnames: any = pageContext.urlParsed.pathname;
|
||||
const pathname: any = pageContext.urlParsed.pathname;
|
||||
|
||||
const notChatPage = pathnames.includes("/chat") ? false : true;
|
||||
const notChannelPage = pathnames.includes("/channel") ? false : true;
|
||||
const isChatPage = pathname.includes("/chat");
|
||||
const isChannelPage = pathname.includes("/channel");
|
||||
// const notSpacePage = pathnames.includes("/space") ? false : true;
|
||||
|
||||
const lastLogin = useActiveAccount((state: any) => state.lastLogin);
|
||||
const notifyChat = useChats((state: any) => state.add);
|
||||
const saveChat = useChatMessages((state: any) => state.add);
|
||||
const notifyChannel = useChannels((state: any) => state.add);
|
||||
|
||||
const { user } = useProfile(data.pubkey);
|
||||
|
||||
useSWRSubscription(
|
||||
user && lastLogin > 0 ? ["account", data.pubkey] : null,
|
||||
([, key]) => {
|
||||
() => {
|
||||
// subscribe to channel
|
||||
const unsubscribe = pool.subscribe(
|
||||
[
|
||||
{
|
||||
"#p": [key],
|
||||
"#p": [data.pubkey],
|
||||
since: lastLogin,
|
||||
},
|
||||
],
|
||||
@@ -42,7 +43,9 @@ export function ActiveAccount({ data }: { data: any }) {
|
||||
case 1:
|
||||
break;
|
||||
case 4:
|
||||
if (notChatPage) {
|
||||
if (!isChatPage) {
|
||||
// save
|
||||
saveChat(data.pubkey, event);
|
||||
// update state
|
||||
notifyChat(event.pubkey);
|
||||
// send native notifiation
|
||||
@@ -50,7 +53,7 @@ export function ActiveAccount({ data }: { data: any }) {
|
||||
}
|
||||
break;
|
||||
case 42:
|
||||
if (notChannelPage) {
|
||||
if (!isChannelPage) {
|
||||
// update state
|
||||
notifyChannel(event);
|
||||
// send native notifiation
|
||||
|
||||
Reference in New Issue
Block a user