parent
7075f4a664
commit
29a1a82cfb
12 changed files with 344 additions and 203 deletions
|
|
@ -1,12 +1,14 @@
|
|||
import { get, writable } from 'svelte/store';
|
||||
import { addNotification, notiStore } from '../stores/noti';
|
||||
import {
|
||||
materialFromServerQuery,
|
||||
recipeData,
|
||||
recipeDataError,
|
||||
recipeLoading,
|
||||
recipeOverviewData,
|
||||
recipeStreamMeta
|
||||
} from '../stores/recipeStore';
|
||||
import { buildOverviewFromServer } from '$lib/data/recipeService';
|
||||
|
||||
export const messages = writable<string[]>([]);
|
||||
|
||||
|
|
@ -82,6 +84,39 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
},
|
||||
stream_data_end: (p) => {
|
||||
recipeLoading.set(false);
|
||||
|
||||
// build overview for recipe from server
|
||||
//
|
||||
|
||||
buildOverviewFromServer();
|
||||
},
|
||||
stream_data_extra: (p) => {
|
||||
// extended data from server, may be extra infos
|
||||
//
|
||||
// expected last stream_id + count
|
||||
let exid = p.exid;
|
||||
let extp = p.extp;
|
||||
let ex_payload = p.payload;
|
||||
|
||||
if (extp) {
|
||||
// know type
|
||||
switch (extp) {
|
||||
case 'matset':
|
||||
let curr_mat_query = get(materialFromServerQuery);
|
||||
// ex_payload has chunks of material setting
|
||||
for (let m of ex_payload) {
|
||||
let mid = m.id;
|
||||
curr_mat_query[mid] = m;
|
||||
}
|
||||
|
||||
materialFromServerQuery.set(curr_mat_query);
|
||||
break;
|
||||
case 'topplist':
|
||||
break;
|
||||
case 'toppgrp':
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
stream_patch_update: (p) => {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ export const recipeFromMachine = writable<any>(null);
|
|||
export const recipeFromMachineLoading = writable(false);
|
||||
export const recipeFromMachineError = writable<string | null>(null);
|
||||
|
||||
export const recipeFromServerQuery = writable<any>({});
|
||||
export const materialFromServerQuery = writable<any>({});
|
||||
|
||||
// NOTE: must not have any nested structures
|
||||
// { recipe: {}, materials: {}, toppings: { groups: {}, lists: {} } }
|
||||
export const recipeFromMachineQuery = writable<any>({});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue