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

feat: move pin extension notification to main screen #902

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const Layout = ({ children, drawerUIDefaultContent, isFullWidth }: Layout
const backgroundServices = useBackgroundServiceAPIContext();

const [showPinExtension, { updateLocalStorage: setShowPinExtension }] = useLocalStorage('showPinExtension', true);
const [showDappBetaModal] = useLocalStorage('showDappBetaModal', true);

useEffect(() => {
const openDrawer = async () => {
Expand All @@ -56,11 +57,19 @@ export const Layout = ({ children, drawerUIDefaultContent, isFullWidth }: Layout
}, [backgroundServices, setTheme]);

useEffect(() => {
const timer = setTimeout(() => {
setShowPinExtension(false);
}, PIN_EXTENSION_TIMEOUT);
return () => clearTimeout(timer);
}, [setShowPinExtension]);
let timer: NodeJS.Timeout;
if (!showDappBetaModal) {
timer = setTimeout(() => {
setShowPinExtension(false);
}, PIN_EXTENSION_TIMEOUT);
}

return () => {
if (timer) {
clearTimeout(timer);
}
};
greatertomi marked this conversation as resolved.
Show resolved Hide resolved
}, [setShowPinExtension, showDappBetaModal]);

const debouncedToast = useMemo(() => debounce(toast.notify, toastThrottle), []);
const showNetworkError = useCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import { useExternalLinkOpener } from '@providers';
import { getValueFromLocalStorage, saveValueInLocalStorage } from '@src/utils/local-storage';
import { WarningModal } from '@src/views/browser-view/components';
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocalStorage } from '@hooks';

export const DappBetaModal = (): React.ReactElement => {
const { t } = useTranslation();
const [isModalVisible, setIsModalVisible] = useState(false);
const [showDappBetaModal, { updateLocalStorage: setShowDappBetaModal }] = useLocalStorage('showDappBetaModal', true);
const openExternalLink = useExternalLinkOpener();

useEffect(() => {
const showDappBetaModal = getValueFromLocalStorage('showDappBetaModal', true);
setIsModalVisible(showDappBetaModal);
}, []);
}, [showDappBetaModal]);

const onClose = () => {
saveValueInLocalStorage({ key: 'showDappBetaModal', value: false });
setShowDappBetaModal(false);
setIsModalVisible(false);
};

const onLearnMore = () => {
const showDappBetaModal = getValueFromLocalStorage('showDappBetaModal', true);
if (showDappBetaModal) openExternalLink(process.env.FAQ_URL);
onClose();
};
Expand Down
Loading