Skip to content

Commit

Permalink
Chat is fixed for Guest Mode and sort imports is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-01k committed Feb 20, 2024
1 parent 9547e78 commit fb6074b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/components/NavigationButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function NavigationButton({ item, data, sectionID, active, bg = 'none' }) {
margin={definedMargin}
bg={bg}
active={active ? 1 : 0}
onClick={disallowNavigation && handleDisallowedNav}
// onClick={disallowNavigation && handleDisallowedNav}
className={data?.name?.toLowerCase()}
>
{data.iconFactory ? (
Expand Down
4 changes: 2 additions & 2 deletions src/config/NavigationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const NavigationList = {
isRoute: true,
hasMenuLogic: true,
hidden: false,
allowReadOnly: false,
// allowReadOnly: false,
headerTag: {
title: 'Chat',
light: {
Expand All @@ -96,7 +96,7 @@ const NavigationList = {
isRoute: true,
hasMenuLogic: true,
hidden: false,
allowReadOnly: false,
// allowReadOnly: false,
headerTag: {
title: 'Spaces',
light: {
Expand Down
14 changes: 7 additions & 7 deletions src/contexts/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ProgressHookType, PushAPI } from '@pushprotocol/restapi';


// Internal Components
import { AppContextType, BlockedLoadingI, ConnectedPeerIDType, LocalPeerType, Web3NameListType, onboardingProgressI } from "types/context"
import { AppContextType, BlockedLoadingI, ConnectedPeerIDType, LocalPeerType, onboardingProgressI, Web3NameListType } from "types/context"
import { useAccount } from "hooks";
import { appConfig } from "config";
import { useDispatch, useSelector } from "react-redux";
Expand Down Expand Up @@ -125,7 +125,7 @@ const AppContextProvider = ({ children }) => {
hookInfo: progressHook,
spinnerType: LOADER_SPINNER_TYPE.PROCESSING,
progress: 0,
errorMessage:''
errorMessage: ''
};

if (progressHook) {
Expand Down Expand Up @@ -194,17 +194,17 @@ const AppContextProvider = ({ children }) => {
onboardingProgress.progress = 99;
break;
case "PUSH-ERROR-00":
onboardingProgress.errorMessage="User Rejected Signature";
onboardingProgress.errorMessage = "User Rejected Signature";
onboardingProgress.hookInfo.progressTitle = "User Rejected Signature";
onboardingProgress.spinnerType = LOADER_SPINNER_TYPE.ERROR;
break;
case "PUSH-ERROR-01":
onboardingProgress.errorMessage="Upgrade Failed";
onboardingProgress.errorMessage = "Upgrade Failed";
onboardingProgress.hookInfo.progressTitle = "Upgrade Failed";
onboardingProgress.spinnerType = LOADER_SPINNER_TYPE.ERROR;
break;
case "PUSH-ERROR-02":
onboardingProgress.errorMessage="Decrypting Keys Failed";
onboardingProgress.errorMessage = "Decrypting Keys Failed";
onboardingProgress.hookInfo.progressTitle = "Decrypting Keys Failed";
onboardingProgress.spinnerType = LOADER_SPINNER_TYPE.ERROR;
break;
Expand All @@ -221,7 +221,7 @@ const AppContextProvider = ({ children }) => {
progressEnabled: onboardingProgress.progress ? true : false,
progress: onboardingProgress.progress,
progressNotice: onboardingProgress.hookInfo.progressInfo,
errorMessage:onboardingProgress.errorMessage,
errorMessage: onboardingProgress.errorMessage,
});

};
Expand All @@ -230,7 +230,7 @@ const AppContextProvider = ({ children }) => {
let userInstance;
try {
const librarySigner = provider?.getSigner(account);
userInstance = await PushAPI.initialize(librarySigner!,{
userInstance = await PushAPI.initialize(librarySigner!, {
env: appConfig.appEnv,
account: account,
progressHook: onboardingProgressReformatter,
Expand Down
20 changes: 16 additions & 4 deletions src/sections/chat/ChatSidebarSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import NewTag from 'components/NewTag';
// Internal Configs
import GLOBALS from 'config/Globals';
import { appConfig } from '../../config';
import { useAccount } from 'hooks';


const createGroupOnMouseEnter = [
Expand Down Expand Up @@ -69,7 +70,7 @@ const ChatSidebarSection = ({ showCreateGroupModal, autofilledSearch }) => {

const isNewTagVisible = getIsNewTagVisible(new Date('2023-02-22T00:00:00.000'), 90);

const { connectedUser, displayQR, setDisplayQR, initializePushSDK } = useContext(AppContext);
const { connectedUser, displayQR, setDisplayQR, initializePushSDK, handleConnectWallet } = useContext(AppContext);
const [searchedUser, setSearchedUser] = useState<string>('');

const { activeTab, setActiveTab } = useContext(Context);
Expand Down Expand Up @@ -100,16 +101,27 @@ const ChatSidebarSection = ({ showCreateGroupModal, autofilledSearch }) => {
}
return formattedChatParticipant;
} else {
await initializePushSDK();
return null;
if (userPushSDKInstance.account === '0x0000000000000000000000000000000000000000') {
handleConnectWallet();
} else if (userPushSDKInstance.signer === undefined || userPushSDKInstance.decryptedPgpPvtKey === undefined) {
await initializePushSDK();
return null;
}
}
}

const handleCreateGroup = async () => {
if (userPushSDKInstance.decryptedPgpPvtKey) {
showCreateGroupModal();
} else {
await initializePushSDK();
if (userPushSDKInstance.account === '0x0000000000000000000000000000000000000000') {
handleConnectWallet();
} else {
if (userPushSDKInstance.signer === undefined) {
await initializePushSDK();
return null;
}
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/structure/MasterInterfacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { lazy, Suspense } from 'react';
// External Packages
import { VscClose } from 'react-icons/vsc';
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
import { ToastContainer, toast } from 'react-toastify';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.min.css';
import styled from 'styled-components';
import { MdError } from 'react-icons/md';
Expand Down Expand Up @@ -104,13 +104,13 @@ function MasterInterfacePage() {
<Routes>
<Route path={APP_PATHS.Inbox} element={<InboxPage />} />
<Route path={APP_PATHS.Spam} element={<InboxPage />} />
<Route element={<ConnectedWalletRoute />}>
{/* <Route element={<ConnectedWalletRoute />}> */}
<Route path={`${APP_PATHS.Chat}/:chatid`} element={<ChatPage />} />
<Route path={APP_PATHS.Chat} element={<ChatPage />} />
<Route path={`${APP_PATHS.Spaces}/:spaceid`} element={<SpacePage />} />
<Route path={APP_PATHS.Spaces} element={<SpacePage />} />
{/* <Route path="chat-new" element={<NewChatPage />} /> */}
</Route>
{/* </Route> */}

<Route
path={APP_PATHS.Channels}
Expand Down

0 comments on commit fb6074b

Please sign in to comment.