Skip to content

Commit

Permalink
add axios retries to background sync functions
Browse files Browse the repository at this point in the history
  • Loading branch information
secondl1ght committed Apr 22, 2023
1 parent 4e5fcdf commit ce67004
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/sync/areas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import localforage from 'localforage';
import axios from 'axios';
import axiosRetry from 'axios-retry';
import { areas, areaError } from '$lib/store';

axiosRetry(axios, { retries: 3 });

export const areasSync = async () => {
// get areas from local
await localforage
Expand Down
3 changes: 3 additions & 0 deletions src/lib/sync/elements.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import localforage from 'localforage';
import axios from 'axios';
import axiosRetry from 'axios-retry';
import { elements, mapUpdates, elementError, mapLoading, elementsSyncCount } from '$lib/store';
import { get } from 'svelte/store';

axiosRetry(axios, { retries: 3 });

export const elementsSync = async () => {
mapLoading.set('Checking local cache...');
// get elements from local
Expand Down
3 changes: 3 additions & 0 deletions src/lib/sync/events.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import localforage from 'localforage';
import axios from 'axios';
import axiosRetry from 'axios-retry';
import { events, eventError } from '$lib/store';

axiosRetry(axios, { retries: 3 });

export const eventsSync = async () => {
// get events from local
await localforage
Expand Down
3 changes: 3 additions & 0 deletions src/lib/sync/reports.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import localforage from 'localforage';
import axios from 'axios';
import axiosRetry from 'axios-retry';
import { reports, reportError } from '$lib/store';

axiosRetry(axios, { retries: 3 });

export const reportsSync = async () => {
// get reports from local
await localforage
Expand Down
3 changes: 3 additions & 0 deletions src/lib/sync/users.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import localforage from 'localforage';
import axios from 'axios';
import axiosRetry from 'axios-retry';
import { users, userError } from '$lib/store';

axiosRetry(axios, { retries: 3 });

export const usersSync = async () => {
// clear potentially broken users v1 sync due to top level ID changing from string to int
await localforage
Expand Down

0 comments on commit ce67004

Please sign in to comment.