| | |
| | | this.items = new Map(); |
| | | this.subscribers = new Set(); |
| | | this.loadFromStorage = false; |
| | | this.failedFetches = 0; |
| | | |
| | | this.api = jvbSettings.api; |
| | | this.endpoint = 'queue'; |
| | |
| | | if (result.id && operation.id !== result.id) { |
| | | operation = await this.handleServerMerge(operation, result); |
| | | } else { |
| | | operation.status = result.status??'failed'; |
| | | operation.status = result.status??'pending'; |
| | | operation.serverData = result; |
| | | this.updateOperationStatus(operation.id, operation.status); |
| | | } |
| | |
| | | try { |
| | | this.ui.refresh.button.classList.add('fetching'); |
| | | this.store.clearCache(); |
| | | await this.store.fetch(); |
| | | let response = await this.store.fetch(); |
| | | if (response.status === 429) { |
| | | console.log('Too many requests. Waiting 30 seconds'); |
| | | this.stopPolling(); |
| | | this.startCountdown(30, () => this.runPollCycle()); |
| | | return; |
| | | } |
| | | |
| | | this.ui.refresh.button.classList.remove('fetching'); |
| | | if (!this.maybeStartPolling()) { |
| | | this.stopPolling(); |
| | |
| | | return; |
| | | } |
| | | } catch (error) { |
| | | this.stopPolling(); |
| | | this.updatePanel('synced'); |
| | | console.error('Polling error:', error); |
| | | } |
| | | |