Skip to content

Commit

Permalink
fix> small changes to timeout for tools bitraf#61
Browse files Browse the repository at this point in the history
  • Loading branch information
clehre committed Jun 30, 2024
1 parent 8cd4435 commit 2812e69
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions web/src/p2k16/web/static/p2k16/p2k16.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,15 @@
);
};

self.debounce = 0;
self.debounce = 400; // prevents most doubleclicks. most people will see the warning before they click again
self.recent_events = recent_events;
self.my_account = P2k16.currentAccount().id;
update(tools);

const debounce = (func, wait) => {
let timeout;
return (...args) => {
P2k16.addInfos(`Waiting for ${args[0].name} to respond`)
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), wait);
};
Expand All @@ -780,7 +781,7 @@
const checkoutTool = (tool) => {
ToolDataService.checkout_tool({ tool: tool.id }).then((res) =>
update(res.data)
);
)
};

const checkinTool = (tool) => {
Expand All @@ -795,12 +796,12 @@
`Do you really want to checkout ${tool.name}? This may destroy a job in progress!`
)
) {
debounce(checkoutTool, 300)(tool);
debounce(checkoutTool, self.debounce)(tool);
}
};

self.checkoutTool = debounce(checkoutTool, 300);
self.checkinTool = debounce(checkinTool, 300);
self.checkoutTool = debounce(checkoutTool, self.debounce);
self.checkinTool = debounce(checkinTool, self.debounce);
}
/*************************************************************************
* Badges
Expand Down

0 comments on commit 2812e69

Please sign in to comment.