mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 00:00:27 +00:00
refresh items table when new item is added
This commit is contained in:
parent
c5c9da6a7e
commit
8d8f8e7014
2 changed files with 7 additions and 1 deletions
|
@ -40,6 +40,7 @@ function connect(onmessage: (m: EventMessage) => void) {
|
|||
export function onServerEvent(event: ServerEvent, callback: () => void) {
|
||||
if (socket === null) {
|
||||
connect(e => {
|
||||
console.debug("received event", e);
|
||||
listeners.get(e.event)?.forEach(c => c());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { UserClient } from "~~/lib/api/user";
|
||||
|
||||
export function itemsTable(api: UserClient) {
|
||||
const { data: items } = useAsyncData(async () => {
|
||||
const { data: items, refresh } = useAsyncData(async () => {
|
||||
const { data } = await api.items.getAll({
|
||||
page: 1,
|
||||
pageSize: 5,
|
||||
|
@ -10,6 +10,11 @@ export function itemsTable(api: UserClient) {
|
|||
return data.items;
|
||||
});
|
||||
|
||||
onServerEvent(ServerEvent.ItemMutation, () => {
|
||||
console.log("item mutation");
|
||||
refresh();
|
||||
});
|
||||
|
||||
return computed(() => {
|
||||
return {
|
||||
items: items.value || [],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue