fix importer erorrs + limit fn calls on import

This commit is contained in:
Hayden 2023-08-02 15:51:15 -05:00
parent 1df47ef668
commit 9c618c89eb
No known key found for this signature in database
GPG key ID: 17CF79474E257545
2 changed files with 11 additions and 5 deletions

View file

@ -86,8 +86,6 @@
importRef.value?.click();
}
const eventBus = useEventBus();
async function submitCsvFile() {
if (!importCsv.value) {
toast.error("Please select a file to import.");
@ -111,8 +109,6 @@
importRef.value.value = "";
}
eventBus.emit(EventTypes.InvalidStores);
toast.success("Import successful!");
}
</script>

View file

@ -30,8 +30,18 @@ function connect(onmessage: (m: EventMessage) => void) {
console.error("websocket error", err);
};
const thorttled = new Map<ServerEvent, any>();
thorttled.set(ServerEvent.LocationMutation, useThrottleFn(onmessage, 1000));
thorttled.set(ServerEvent.ItemMutation, useThrottleFn(onmessage, 1000));
thorttled.set(ServerEvent.LabelMutation, useThrottleFn(onmessage, 1000));
ws.onmessage = msg => {
onmessage(JSON.parse(msg.data));
const pm = JSON.parse(msg.data);
const fn = thorttled.get(pm.event);
if (fn) {
fn(pm);
}
};
socket = ws;