Skip to content

Commit

Permalink
add restore history button (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Polyakov authored Dec 26, 2022
1 parent e7d3564 commit 2695e80
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/store/bridge/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const actions = defineActions({
return bridgeHistory;
},
// TODO: Need to restore transactions for all networks
async updateHistory(context): Promise<void> {
async updateHistory(context, clearHistory = false): Promise<void> {
const { commit, state, dispatch, rootState, rootGetters } = bridgeActionContext(context);
if (state.historyLoading) return;

Expand All @@ -109,6 +109,10 @@ const actions = defineActions({
const contracts = compact(contractsArray);
const updateCallback = () => commit.setHistory();

if (clearHistory) {
await bridgeHistory.clearHistory(updateCallback);
}

await bridgeHistory.updateAccountHistory(address, assets, networkFees, contracts, updateCallback);

commit.setHistoryLoading(false);
Expand Down
6 changes: 6 additions & 0 deletions src/utils/bridge/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ export class EthBridgeHistory {
return history as HistoryElement[];
}

public async clearHistory(updateCallback?: FnWithoutArgs | AsyncFnWithoutArgs): Promise<void> {
this.historySyncTimestamp = 0;
bridgeApi.clearHistory();
await updateCallback?.();
}

public async updateAccountHistory(
address: string,
assets: Record<string, Asset>,
Expand Down
14 changes: 11 additions & 3 deletions src/views/BridgeTransactionsHistory.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<template>
<div class="history-container">
<s-card v-loading="parentLoading" class="history-content" border-radius="medium" shadow="always" primary>
<generic-page-header has-button-back :title="t('bridgeHistory.title')" @back="handleBack" />
<generic-page-header has-button-back :title="t('bridgeHistory.title')" @back="handleBack">
<s-button
type="action"
icon="arrows-swap-90-24"
:disabled="historyLoading"
:tooltip="t('bridgeHistory.restoreHistory')"
@click="updateHistory(true)"
/>
</generic-page-header>
<s-form class="history-form" :show-message="false">
<search-input
v-if="history.length"
Expand Down Expand Up @@ -94,8 +102,8 @@ export default class BridgeTransactionsHistory extends Mixins(
mixins.NumberFormatterMixin
) {
@state.assets.registeredAssets private registeredAssets!: Array<RegisteredAccountAsset>;
@action.bridge.updateHistory private updateHistory!: AsyncFnWithoutArgs;
@state.bridge.historyLoading historyLoading!: boolean;
@action.bridge.updateHistory private updateHistory!: (clearHistory?: boolean) => Promise<void>;
@getter.bridge.historyPage historyPage!: number;
Expand Down

0 comments on commit 2695e80

Please sign in to comment.