Skip to content

Commit

Permalink
feat: handle scanning latest announcements from last fetched block
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomariscal committed Jun 25, 2024
1 parent 1c43d4d commit c5ad0bb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
29 changes: 25 additions & 4 deletions frontend/src/components/AccountReceiveTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,31 @@
{{ formatTime(mostRecentAnnouncementTimestamp * 1000) }}
</div>

<!-- Fetching status -->
<div v-if="scanStatus !== 'complete' && scanStatus !== 'waiting'" class="fetching-status text-italic">
{{ $t('Receive.fetching-latest-from-last-fetched-block') }}
<q-spinner-dots color="primary" size="1em" class="q-ml-xs" />
<!-- Status messages -->
<div
v-if="
['fetching', 'fetching latest', 'scanning', 'scanning latest from last fetched block'].includes(
scanStatus
)
"
class="status-message text-italic"
>
<div v-if="scanStatus === 'fetching' || scanStatus === 'fetching latest'">
{{
scanStatus === 'fetching'
? $t('Receive.fetching')
: $t('Receive.fetching-latest-from-last-fetched-block')
}}
<q-spinner-dots color="primary" size="1em" class="q-ml-xs" />
</div>
<div v-else>
{{
scanStatus === 'scanning latest from last fetched block'
? $t('Receive.scanning-latest-from-last-fetched-block')
: $t('Receive.scanning')
}}
<q-spinner-dots color="primary" size="1em" class="q-ml-xs" />
</div>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"fetching-latest-from-last-fetched-block": "Fetching latest announcements...",
"scanning": "Scanning all announcements for funds...",
"scanning-latest": "Scanning latest announcements for funds...",
"scanning-latest-from-last-fetched-block": "Scanning latest announcements...",
"wait": "This may take a couple of minutes depending on your connection and device. This is normal&mdash; please be patient.",
"stop": "Stop"
},
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"scanning": "在所有的公告中扫描资金...",

"scanning-latest": "在最新公告中扫描资金...",
"scanning-latest-from-last-fetched-block": "在最新公告中扫描资金...",
"wait": "这可能需要几分钟,具体取决于您的连接和设备。这是正常的 — 请耐心等待。",
"stop": "停止"
},
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/pages/AccountReceive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function useScan() {
| 'fetching latest'
| 'scanning'
| 'scanning latest'
| 'scanning latest from last fetched block'
| 'complete'
| 'complete latest';
const scanStatus = ref<ScanStatus>('waiting');
Expand Down Expand Up @@ -391,6 +392,8 @@ function useScan() {
// Reset paused state
paused.value = false;
if (!umbra.value) throw new Error('No umbra instance found. Please make sure you are on a supported network');
const isInitialScan = userAnnouncements.value.length === 0;
scanStatus.value = 'fetching latest';
// Check for manually entered private key in advancedMode, otherwise use the key from user's signature
Expand Down Expand Up @@ -509,7 +512,7 @@ function useScan() {
announcementsQueue = [...announcementsQueue, ...announcementsBatch];
if (announcementsCount == 10000) {
scanStatus.value = 'scanning latest';
scanStatus.value = isInitialScan ? 'scanning latest' : 'scanning latest from last fetched block';
firstScanPromise = filterUserAnnouncementsAsync(spendingPubKey, viewingPrivKey, announcementsQueue);
announcementsQueue = [];
}
Expand All @@ -522,7 +525,7 @@ function useScan() {
await firstScanPromise;
// Clear out existing workers
workers.length = 0;
scanStatus.value = 'scanning';
scanStatus.value = isInitialScan ? 'scanning' : 'scanning latest from last fetched block';
await filterUserAnnouncementsAsync(spendingPubKey, viewingPrivKey, announcementsQueue);
scanStatus.value = 'complete';
Expand Down

0 comments on commit c5ad0bb

Please sign in to comment.