Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read only and Guest Mode feature for dapp #1346

Merged
merged 36 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dd5a88e
Read Only Mode and Guest Mode Feature on the dApp
abhishek-01k Dec 5, 2023
3f272e8
Opt-In is now working in guest mode
abhishek-01k Dec 6, 2023
c69c1dc
Read Only and Guest Mode title added to Profile header
abhishek-01k Dec 6, 2023
0da6fa9
refactor: global context
kalashshah Dec 6, 2023
f8555dc
chore: reset readonlymode when wallet connects
kalashshah Dec 6, 2023
1a6f98a
refactor: memoize return values in useAccount
kalashshah Dec 6, 2023
8e4da61
Merge pull request #1333 from ethereum-push-notification-service/Dapp…
kalashshah Dec 6, 2023
be3d508
fix: missing dependency in account value
kalashshah Dec 6, 2023
0f6e510
Revert "fix: missing dependency in account value"
kalashshah Dec 6, 2023
7c24873
fix: missing dependency in account value
kalashshah Dec 6, 2023
758304c
Opt-In and Opt-Out and send Notification buttons are all done with gu…
abhishek-01k Dec 6, 2023
2064719
chore: support chat in guest mode
kalashshah Dec 6, 2023
975ad91
Dark Mode added in login page
abhishek-01k Dec 7, 2023
e4522f2
chore: chat in read only mode
kalashshah Dec 7, 2023
57a6440
Merge pull request #1335 from ethereum-push-notification-service/chor…
abhishek-01k Dec 7, 2023
a729c1a
Merge pull request #1334 from ethereum-push-notification-service/Dapp…
abhishek-01k Dec 7, 2023
412bb3b
fix: global context merge issues
kalashshah Dec 8, 2023
182559a
Revert "chore: support chat in guest mode"
kalashshah Dec 8, 2023
66530e3
chore: create protected routes and allow only connected wallets
kalashshah Dec 8, 2023
826702f
fix: ui hides behinds modal bug
kalashshah Dec 8, 2023
dceeb4f
chore: show connect modal after nav error
kalashshah Dec 8, 2023
6e2b236
fix: show modal again if wallet not connected and modal closed
kalashshah Dec 8, 2023
3a0d9e5
Merge pull request #1336 from ethereum-push-notification-service/reve…
abhishek-01k Dec 12, 2023
1400039
Read only for notification settings
abhishek-01k Dec 12, 2023
d57bc15
Merge pull request #1337 from ethereum-push-notification-service/Noti…
kalashshah Dec 12, 2023
e5eb9ee
refactor: speed up login page ui load
kalashshah Dec 14, 2023
dab0e06
ui: blur onboard modal bg using mutationobserver
kalashshah Dec 14, 2023
8360ce3
chore: fix z-index for web3-onboard modals
kalashshah Dec 14, 2023
abba9cc
Merge pull request #1339 from ethereum-push-notification-service/ui/o…
abhishek-01k Dec 15, 2023
aad62af
Create Channel in guest mode
abhishek-01k Dec 15, 2023
9c6b5f6
chore: protect yield farming fns in read only mode
kalashshah Dec 15, 2023
ca4cdd4
Merge pull request #1340 from ethereum-push-notification-service/Crea…
kalashshah Dec 15, 2023
8e3bbf1
ui: always hide web3 modal after login
kalashshah Dec 15, 2023
3d00aee
Merge pull request #1342 from ethereum-push-notification-service/ui/h…
abhishek-01k Dec 15, 2023
fa2bbdd
Merge pull request #1341 from ethereum-push-notification-service/chor…
kalashshah Dec 18, 2023
5eef39b
Removed consoles
abhishek-01k Dec 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 63 additions & 78 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { PushAPI } from '@pushprotocol/restapi';
// Internal Compoonents
import InitState from 'components/InitState';
import NavigationContextProvider from 'contexts/NavigationContext';
import AppContextProvider from 'contexts/AppContext';
import AppContextProvider, { AppContext } from 'contexts/AppContext';
import { EnvHelper } from 'helpers/UtilityHelper';
import { useAccount, useInactiveListener, useSDKSocket } from 'hooks';
import UserJourneySteps from 'segments/userJourneySteps';
Expand All @@ -31,7 +31,7 @@ import { resetCanSendSlice } from 'redux/slices/sendNotificationSlice';
import { resetChannelCreationSlice } from 'redux/slices/channelCreationSlice';
import { resetAdminSlice } from 'redux/slices/adminSlice';
import Navigation from 'structure/Navigation';
import { ErrorContext } from './contexts/ErrorContext'
import { ErrorContext } from './contexts/ErrorContext'
import { resetUserSlice, setUserPushSDKInstance } from 'redux/slices/userSlice';

// Internal Configs
Expand All @@ -43,7 +43,7 @@ import { ChatUserContext } from 'contexts/ChatUserContext';
// space imports
import SpaceContextProvider, { SpaceContext } from 'contexts/SpaceContext';
import { SpacesUIProvider } from '@pushprotocol/uiweb';
import { darkTheme,lightTheme } from 'config/spaceTheme';
import { darkTheme, lightTheme } from 'config/spaceTheme';
import { SpaceWidgetSection } from 'sections/space/SpaceWidgetSection';
import {
ISpaceBannerProps,
Expand Down Expand Up @@ -77,9 +77,9 @@ export interface IUseSpaceReturnValues {
export default function App() {
const dispatch = useDispatch();

const {isActive, account, chainId, provider} = useAccount();
const { isActive, account, chainId, provider } = useAccount();
const [currentTime, setcurrentTime] = React.useState(0);
const {authError, setAuthError } = useContext(ErrorContext);
const { authError, setAuthError } = useContext(ErrorContext);
const updateOnboardTheme = useUpdateTheme();
const { userPushSDKInstance } = useSelector((state: any) => {
return state.user;
Expand All @@ -101,7 +101,7 @@ export default function App() {
}, []);

useEffect(() => {
if(!account) return;
if (!account) return;
dispatch(resetSpamSlice());
dispatch(resetNotificationsSlice());
dispatch(resetCanSendSlice());
Expand All @@ -110,25 +110,6 @@ export default function App() {
dispatch(resetUserSlice());
}, [account]);

useEffect(() => {
const librarySigner = provider?.getSigner(account);
if(!account || !librarySigner || !appConfig?.appEnv || userPushSDKInstance) return;

const initializePushSDK = async () => {
try {
const userInstance = await PushAPI.initialize(librarySigner, {
env: appConfig.appEnv, // defaults to staging
account: account
});

dispatch(setUserPushSDKInstance(userInstance));
} catch (error) {
// Handle initialization error
}
};

initializePushSDK();
}, [account, provider]);

// console.log(isActive, chainId, account);
// handle logic to reconnect in response to certain events from the provider
Expand All @@ -143,8 +124,8 @@ export default function App() {
const [darkMode, setDarkMode] = useState(false);

// enable socket notifications
useSDKSocket({ account, chainId, env: appConfig.appEnv});
useSDKSocket({ account, chainId, env: appConfig.appEnv });

const toggleDarkMode = () => {
const newTheme = !darkMode ? 'dark' : 'light';
updateOnboardTheme(newTheme);
Expand Down Expand Up @@ -230,6 +211,7 @@ export default function App() {
const location = useLocation();
const isSnapPage = location?.pathname === '/snap';


return (
<ThemeProvider theme={darkMode ? themeDark : themeLight}>
{(!isActive || !allowedChain) && (
Expand All @@ -238,71 +220,74 @@ export default function App() {
</SectionV2>
)}

{isActive && !authError && allowedChain && (

{isActive && !authError && (
<>
<GlobalStyle />
<InitState />
<NavigationContextProvider>
<SpaceContextProvider>
<SpaceComponentContextProvider spaceUI={spaceUI}>
<AppContextProvider>
<Joyride
run={run}
steps={steps}
continuous={tutorialContinous}
stepIndex={stepIndex}
// hideFooter={true}
// primaryProps={false}
hideBackButton={true}
hideCloseButton={false}
disableScrolling={true}
disableScrollParentFix={true}
// disableFlip={true}
// showNextButton={false}
showSkipButton={false}
disableOverlayClose={true}
callback={handleJoyrideCallback}
styles={{
options: {
arrowColor: darkMode ? themeDark.dynamicTutsBg : themeLight.dynamicTutsBg,
backgroundColor: darkMode ? themeDark.dynamicTutsBg : themeLight.dynamicTutsBg,
overlayColor: darkMode ? themeDark.dynamicTutsBgOverlay : themeLight.dynamicTutsBgOverlay,
primaryColor: darkMode ? themeDark.dynamicTutsPrimaryColor : themeLight.dynamicTutsPrimaryColor,
textColor: darkMode ? themeDark.dynamicTutsFontColor : themeLight.dynamicTutsFontColor,
zIndex: 1000,
},
}}
/>

<HeaderContainer>
<Header
isDarkMode={darkMode}
darkModeToggle={toggleDarkMode}
{/* <AppContextProvider> */}
<Joyride
run={run}
steps={steps}
continuous={tutorialContinous}
stepIndex={stepIndex}
// hideFooter={true}
// primaryProps={false}
hideBackButton={true}
hideCloseButton={false}
disableScrolling={true}
disableScrollParentFix={true}
// disableFlip={true}
// showNextButton={false}
showSkipButton={false}
disableOverlayClose={true}
callback={handleJoyrideCallback}
styles={{
options: {
arrowColor: darkMode ? themeDark.dynamicTutsBg : themeLight.dynamicTutsBg,
backgroundColor: darkMode ? themeDark.dynamicTutsBg : themeLight.dynamicTutsBg,
overlayColor: darkMode ? themeDark.dynamicTutsBgOverlay : themeLight.dynamicTutsBgOverlay,
primaryColor: darkMode ? themeDark.dynamicTutsPrimaryColor : themeLight.dynamicTutsPrimaryColor,
textColor: darkMode ? themeDark.dynamicTutsFontColor : themeLight.dynamicTutsFontColor,
zIndex: 1000,
},
}}
/>
</HeaderContainer>

<ParentContainer
bg={darkMode ? themeDark.backgroundBG : !isActive ? themeLight.connectWalletBg : themeLight.backgroundBG}
headerHeight={GLOBALS.CONSTANTS.HEADER_HEIGHT}
>
{!isSnapPage && <LeftBarContainer leftBarWidth={GLOBALS.CONSTANTS.LEFT_BAR_WIDTH}>
<Navigation />
</LeftBarContainer>}

<ContentContainer leftBarWidth={isSnapPage ? 0 : GLOBALS.CONSTANTS.LEFT_BAR_WIDTH}>
{/* Shared among all pages, load universal things here */}
<SpacesUIProvider spaceUI={spaceUI} theme={darkMode ? darkTheme : lightTheme}>

<HeaderContainer>
<Header
isDarkMode={darkMode}
darkModeToggle={toggleDarkMode}
/>
</HeaderContainer>

<ParentContainer
bg={darkMode ? themeDark.backgroundBG : !isActive ? themeLight.connectWalletBg : themeLight.backgroundBG}
headerHeight={GLOBALS.CONSTANTS.HEADER_HEIGHT}
>
{!isSnapPage && <LeftBarContainer leftBarWidth={GLOBALS.CONSTANTS.LEFT_BAR_WIDTH}>
<Navigation />
</LeftBarContainer>}

<ContentContainer leftBarWidth={isSnapPage ? 0 : GLOBALS.CONSTANTS.LEFT_BAR_WIDTH}>
{/* Shared among all pages, load universal things here */}
<SpacesUIProvider spaceUI={spaceUI} theme={darkMode ? darkTheme : lightTheme}>
<MasterInterfacePage />
<SpaceWidgetSection />
</SpacesUIProvider>
</ContentContainer>
</ParentContainer>
</AppContextProvider>
</SpaceComponentContextProvider>
</ContentContainer>
</ParentContainer>
{/* </AppContextProvider> */}
</SpaceComponentContextProvider>
</SpaceContextProvider>
</NavigationContextProvider>
</>
)}


</ThemeProvider>
);
}
Expand Down
Loading
Loading