mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 00:00:27 +00:00
fix importer erorrs + limit fn calls on import
This commit is contained in:
parent
1df47ef668
commit
9c618c89eb
2 changed files with 11 additions and 5 deletions
|
@ -86,8 +86,6 @@
|
||||||
importRef.value?.click();
|
importRef.value?.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventBus = useEventBus();
|
|
||||||
|
|
||||||
async function submitCsvFile() {
|
async function submitCsvFile() {
|
||||||
if (!importCsv.value) {
|
if (!importCsv.value) {
|
||||||
toast.error("Please select a file to import.");
|
toast.error("Please select a file to import.");
|
||||||
|
@ -111,8 +109,6 @@
|
||||||
importRef.value.value = "";
|
importRef.value.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBus.emit(EventTypes.InvalidStores);
|
|
||||||
|
|
||||||
toast.success("Import successful!");
|
toast.success("Import successful!");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -30,8 +30,18 @@ function connect(onmessage: (m: EventMessage) => void) {
|
||||||
console.error("websocket error", err);
|
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 => {
|
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;
|
socket = ws;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue