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

add reload button #520

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions public/assets/images/popup/reload.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 38 additions & 31 deletions src/extension/components/shell-popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,32 @@ const ShellPopUp: React.FC<Props> = ({

const [updating, setUpdating] = useState(false);

const goToHomeOrUpdate = async () => {
if (history.location.pathname !== DEFAULT_ROUTE) {
await sendFlowRepository.reset();
history.push(DEFAULT_ROUTE);
} else {
if (updating) return;
setUpdating(true);
try {
const updater = new UpdaterService(
walletRepository,
appRepository,
blockHeadersRepository,
assetRepository,
await zkp()
);
if (!cache?.network) throw new Error('Network not found');
await updater.checkAndFixMissingTransactionsData(cache.network);
} catch (e) {
console.error(e);
} finally {
setUpdating(false);
}
const goToHome = async () => {
if (history.location.pathname === DEFAULT_ROUTE) return;
await sendFlowRepository.reset();
history.push(DEFAULT_ROUTE);
};

const update = async () => {
if (updating) return;
setUpdating(true);
try {
const updater = new UpdaterService(
walletRepository,
appRepository,
blockHeadersRepository,
assetRepository,
await zkp()
);
if (!cache?.network) throw new Error('Network not found');
await updater.checkAndFixMissingTransactionsData(cache.network);
} catch (e) {
console.error(e);
} finally {
setUpdating(false);
}
};

const handleBackBtn = () => {
if (backBtnCb) {
backBtnCb();
Expand Down Expand Up @@ -141,12 +143,8 @@ const ShellPopUp: React.FC<Props> = ({
<header>
<div className="bg-grayNavBar border-graySuperLight flex flex-row items-center content-center justify-between h-12 border-b-2">
<div className="flex flex-row items-center">
<button onClick={goToHomeOrUpdate}>
<img
className={classNames('px-4', { 'animate-spin': updating })}
src="assets/images/marina-logo.svg"
alt="marina logo"
/>
<button onClick={goToHome}>
<img className="px-4" src="assets/images/marina-logo.svg" alt="marina logo" />
</button>

{cache?.network !== 'liquid' && (
Expand All @@ -160,9 +158,18 @@ const ShellPopUp: React.FC<Props> = ({
)}
</div>
{(isUpdaterLoading || isRestorerLoading) && loader()}
<button disabled={btnDisabled} onClick={openMenuModal}>
<img className="px-4" src="assets/images/popup/dots-vertical.svg" alt="menu icon" />
</button>
<div className="flex flex-row items-center">
<button disabled={btnDisabled} onClick={update}>
<img
className={classNames('px-4', { 'animate-spin': updating })}
src="assets/images/popup/reload.svg"
alt="reload icon"
/>
</button>
<button disabled={btnDisabled} onClick={openMenuModal}>
<img className="pr-4" src="assets/images/popup/dots-vertical.svg" alt="menu icon" />
</button>
</div>
</div>
{nav}
</header>
Expand Down
Loading