Skip to content

Commit

Permalink
Moved chat user context to app context (#1412)
Browse files Browse the repository at this point in the history
* partial commit

* added search and dynamic linking in chatpreviewlist

* fixed dynamic link

* added formatting for .wallet

* Resolve verifier address issue

* Console error and warning fix (#1390)

* fixed button and chatviewlist warning

* fixed memory leak in useeffect

* Push admin address updated

* added chat components

* Added Collapsable Sidebar UI (#1410)

* Sidebar Collapsable new UI and Logic (#1396)

* Sidebar Collapsable new UI and Logic

* Sidebar State persistant and Yield Farming logo done

* Sidebar components are adjusted according to the design

* Module width changes when collapsed

* Fixed the margin of dashboard, send and yield modules

* Removed the arrow in more button

* changes according to code rules

* Tooltip for collapsable sidebar

* name change

* changes

---------

Co-authored-by: Abhishek <[email protected]>

* modified 404 page not found page (#1405)

* fixed button and chatviewlist warning

* fixed memory leak in useeffect

* modified 404 not found page in dapp

* removed unnecessary styles

* few tweaks

---------

Co-authored-by: harshrajat <[email protected]>

* Moved ChatuserContext to AppContext

* fixed reviw bugs

* fixed a bug

* fix: z-index of chat profile & chat preview load on big screen

* Update user is fixed and restapi version updated

* Read only mode active when user rejects signature

* rejection toast is added and chat is ready for read mode

---------

Co-authored-by: harshrajat <[email protected]>
Co-authored-by: Monalisha Mishra <[email protected]>
Co-authored-by: Nilesh Gupta <[email protected]>
Co-authored-by: Satyam <[email protected]>
Co-authored-by: Monalisha Mishra <[email protected]>
Co-authored-by: Pritipriya Singh <[email protected]>
  • Loading branch information
7 people authored Feb 13, 2024
1 parent d7f0d68 commit d9d4ed9
Show file tree
Hide file tree
Showing 50 changed files with 1,316 additions and 1,049 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"@mui/icons-material": "^5.8.4",
"@mui/lab": "^5.0.0-alpha.72",
"@mui/material": "^5.5.0",
"@pushprotocol/restapi": "1.6.1",
"@pushprotocol/restapi": "0.0.1-alpha.64",
"@pushprotocol/socket": "0.5.3",
"@pushprotocol/uiweb": "1.2.5",
"@pushprotocol/uiweb": "0.0.1-alpha.41",
"@reduxjs/toolkit": "^1.7.1",
"@testing-library/dom": "^9.0.1",
"@testing-library/jest-dom": "^4.2.4",
Expand Down
38 changes: 24 additions & 14 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { createGlobalStyle } from 'styled-components';

// Internal Compoonents
import InitState from 'components/InitState';
import AppContextProvider from 'contexts/AppContext';
import AppContextProvider, { AppContext } from 'contexts/AppContext';
import NavigationContextProvider from 'contexts/NavigationContext';
import { useAccount, useInactiveListener, useSDKSocket } from 'hooks';
import { resetAdminSlice } from 'redux/slices/adminSlice';
Expand All @@ -35,7 +35,7 @@ import { setIndex, setRun, setWelcomeNotifsEmpty } from './redux/slices/userJour
import { appConfig } from 'config';
import GLOBALS from 'config/Globals';
import { themeDark, themeLight } from 'config/Themization';
import { ChatUserContext } from 'contexts/ChatUserContext';
import { GlobalContext } from 'contexts/GlobalContext';

// space imports
import {
Expand Down Expand Up @@ -101,7 +101,8 @@ const extendConsole = () => {
extendConsole();

// Disable consolve
if (appConfig?.appEnv === "prod" || appConfig?.appEnv === "staging") {

if (appConfig?.appEnv === "prod") {
console.enable("debug", false);
console.enable("log", false);
console.enable("info", false);
Expand All @@ -112,13 +113,17 @@ if (appConfig?.appEnv === "prod" || appConfig?.appEnv === "staging") {
}
}


// Provess App
export default function App() {
const dispatch = useDispatch();

const { isActive, account, chainId, provider } = useAccount();
const [currentTime, setcurrentTime] = React.useState(0);
const { authError, setAuthError } = useContext(ErrorContext);
const { pgpPvtKey } = useContext<any>(AppContext);
const { sidebarCollapsed, setSidebarCollapsed } = React.useContext(GlobalContext);

const updateOnboardTheme = useUpdateTheme();
const { userPushSDKInstance } = useSelector((state: any) => {
return state.user;
Expand Down Expand Up @@ -161,7 +166,6 @@ export default function App() {

// Initialize Theme
const [darkMode, setDarkMode] = useState(false);

const toggleDarkMode = () => {
const newTheme = !darkMode ? 'dark' : 'light';
updateOnboardTheme(newTheme);
Expand All @@ -178,10 +182,18 @@ export default function App() {
updateOnboardTheme(theme);
document.documentElement.setAttribute('theme', theme);
}

const SidebarCollapsable = localStorage.getItem('SidebarCollapsed');
if (SidebarCollapsable) {
const isSidebarCollapsed = JSON.parse(SidebarCollapsable);
setSidebarCollapsed(isSidebarCollapsed)
}

}, []);

React.useEffect(() => {
localStorage.setItem('theme', JSON.stringify(darkMode));
localStorage.setItem('SidebarCollapsed', JSON.stringify(sidebarCollapsed));
});

React.useEffect(() => {
Expand Down Expand Up @@ -231,8 +243,6 @@ export default function App() {
};

const librarySigner = provider?.getSigner(account);
const { pgpPvtKey } = useContext<any>(ChatUserContext);


const spaceUI = useMemo(() => new SpacesUI({
account: account,
Expand All @@ -250,7 +260,6 @@ export default function App() {

return (
<ThemeProvider theme={darkMode ? themeDark : themeLight}>
<AppContextProvider>
{(!isActive || !allowedChain) && (
<SectionV2 minHeight="100vh">
<AppLogin toggleDarkMode={toggleDarkMode} />
Expand Down Expand Up @@ -304,11 +313,13 @@ export default function App() {
bg={darkMode ? themeDark.backgroundBG : !isActive ? themeLight.connectWalletBg : themeLight.backgroundBG}
headerHeight={GLOBALS.CONSTANTS.HEADER_HEIGHT}
>
{!isSnapPage && <LeftBarContainer leftBarWidth={GLOBALS.CONSTANTS.LEFT_BAR_WIDTH}>
<Navigation />
</LeftBarContainer>}
{!isSnapPage &&
<LeftBarContainer leftBarWidth={sidebarCollapsed ? GLOBALS.CONSTANTS.COLLAPSABLE_LEFT_BAR_WIDTH : GLOBALS.CONSTANTS.LEFT_BAR_WIDTH}>
<Navigation />
</LeftBarContainer>
}

<ContentContainer leftBarWidth={isSnapPage ? 0 : GLOBALS.CONSTANTS.LEFT_BAR_WIDTH}>
<ContentContainer leftBarWidth={sidebarCollapsed ? GLOBALS.CONSTANTS.COLLAPSABLE_RIGHT_BAR_WIDTH : GLOBALS.CONSTANTS.LEFT_BAR_WIDTH}>
{/* Shared among all pages, load universal things here */}
<SpacesUIProvider spaceUI={spaceUI} theme={darkMode ? darkTheme : lightTheme}>
<MasterInterfacePage />
Expand All @@ -321,8 +332,6 @@ export default function App() {
</NavigationContextProvider>
</>
)}

</AppContextProvider>
</ThemeProvider>
);
}
Expand Down Expand Up @@ -358,7 +367,8 @@ const LeftBarContainer = styled.div`
top: 0;
bottom: 0;
width: ${(props) => props.leftBarWidth}px;
position: fixed;
// position: fixed;
position: absolute;
@media (max-width: 992px) {
display: none;
Expand Down
Loading

0 comments on commit d9d4ed9

Please sign in to comment.