Unverified Commit a7232867 authored by mvdbeek's avatar mvdbeek
Browse files

Place watchHistory logic in try/catch/finally

parent 0592013f
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 * submitted, delayed only by the throttle period and the request response time.
 */

import store from "store/index";
import defaultStore from "store/index";
import { urlData } from "utils/url";
import { getCurrentHistoryFromServer } from "./queries";
import { getGalaxyInstance } from "app";
@@ -21,7 +21,7 @@ let lastUpdateTime = null;
// last time changed history items have been requested
let lastRequestDate = new Date();

export async function watchHistory() {
export async function watchHistoryOnce(store) {
    // "Reset" watchTimeout so we don't queue up watchHistory calls in rewatchHistory.
    watchTimeout = null;
    // get current history
@@ -64,10 +64,20 @@ export async function watchHistory() {
            });
        }
    }
}

export async function watchHistory(store = defaultStore) {
    try {
        await watchHistoryOnce(store);
    } catch (error) {
        // would be fantastic if we could show some error alerting the user to this
        console.warn(error);
    } finally {
        watchTimeout = setTimeout(() => {
        watchHistory();
            watchHistory(store);
        }, throttlePeriod);
    }
}

export function rewatchHistory() {
    if (watchTimeout) {