Skip to content

Commit

Permalink
Add mutex for refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
qtc-de committed Sep 8, 2023
1 parent 3d5b551 commit 7d09cb2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions frontend/src/stores/processStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var processTree = [];
var symbols = {};
var symbolExport = {};
var refreshTimer = 30;
var refreshOngoing = false;

var selectedPane = null;
var selectedProcess = null;
Expand All @@ -23,6 +24,7 @@ export const processStore = defineStore(
refreshTimer,
selectedPane,
symbolExport,
refreshOngoing,
selectedProcess,
selectedInterface,
}),
Expand Down Expand Up @@ -203,9 +205,18 @@ export const processStore = defineStore(
{
if (import.meta.env.VITE_OFFLINE_MODE != 0)
{
console.log('Refresh is disabled when running in offline mode.');
return;
}

if (refreshOngoing)
{
console.log('Already refreshing.');
return;
}

refreshOngoing = true;

fetch('/api/process/tree?refresh=true').then( (response) =>
{
if (response.ok)
Expand Down Expand Up @@ -243,6 +254,9 @@ export const processStore = defineStore(
{
console.log('Failed to retrieve process tree from server.');
}
}).finally(() =>
{
refreshOngoing = false;
});
},

Expand Down

0 comments on commit 7d09cb2

Please sign in to comment.