feat: recipe version selector
- fix recipe not show on overview - fix recipe show late after select country - disable queue message on no connection ws - fix infinite topping(s) list if moving between pages Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
parent
e25881d016
commit
a29ff0be1a
19 changed files with 314 additions and 108 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { get, writable } from 'svelte/store';
|
||||
import { addNotification, notiStore } from '../stores/noti';
|
||||
import {
|
||||
currentRecipeVersionsSelector,
|
||||
materialFromServerQuery,
|
||||
recipeData,
|
||||
recipeDataError,
|
||||
|
|
@ -12,6 +13,8 @@ import {
|
|||
} from '../stores/recipeStore';
|
||||
import { buildOverviewFromServer } from '$lib/data/recipeService';
|
||||
import { auth } from '../client/firebase';
|
||||
import { type RecipeVersion } from '$lib/models/recipe_version.model';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
export const messages = writable<string[]>([]);
|
||||
|
||||
|
|
@ -32,18 +35,30 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
let stream_id = p.stream_id;
|
||||
let total_size = p.total_size;
|
||||
let chunk_size = p.chunk_size;
|
||||
let data_meta = p.metadata;
|
||||
|
||||
if (stream_id) {
|
||||
addNotification('INFO:Start streaming data');
|
||||
|
||||
let meta_list = data_meta?.split(',');
|
||||
let version = meta_list[0]?.split('=')[1] ?? '';
|
||||
let country = meta_list[1]?.split('=')[1] ?? '';
|
||||
|
||||
// recipeLoading.set(true);
|
||||
recipeStreamMeta.set({
|
||||
id: stream_id,
|
||||
total_size: total_size,
|
||||
chunk_size: chunk_size,
|
||||
progress: 0
|
||||
progress: 0,
|
||||
version,
|
||||
country
|
||||
});
|
||||
recipeData.set([]);
|
||||
recipeOverviewData.set([]);
|
||||
|
||||
materialFromServerQuery.set([]);
|
||||
toppingListFromServerQuery.set([]);
|
||||
toppingGroupFromServerQuery.set([]);
|
||||
}
|
||||
},
|
||||
stream_data_error: (p) => {
|
||||
|
|
@ -56,6 +71,7 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
},
|
||||
stream_data_chunk: (p) => {
|
||||
let current_meta = get(recipeStreamMeta);
|
||||
// console.log('current meta', current_meta);
|
||||
if (current_meta) {
|
||||
let stream_id = current_meta.id;
|
||||
|
||||
|
|
@ -92,6 +108,7 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
// build overview for recipe from server
|
||||
//
|
||||
|
||||
// console.log('ending stream');
|
||||
buildOverviewFromServer();
|
||||
},
|
||||
stream_data_extra: (p) => {
|
||||
|
|
@ -120,7 +137,7 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
curr_mat_query.push(m);
|
||||
}
|
||||
|
||||
// console.log('current materials: ', JSON.stringify(curr_mat_query));
|
||||
// // console.log('current materials: ', JSON.stringify(curr_mat_query));
|
||||
materialFromServerQuery.set(curr_mat_query);
|
||||
break;
|
||||
case 'topplist':
|
||||
|
|
@ -168,6 +185,28 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
// broadcast to all
|
||||
addNotification(`${noti_level}:${msg}`);
|
||||
}
|
||||
},
|
||||
ui_action: (p) => {
|
||||
if (p.action == 'refreshNow' && p.from == 'brew') {
|
||||
goto('/tools/brew');
|
||||
}
|
||||
},
|
||||
version_selectors: (p) => {
|
||||
if (p.versions.length > 0) {
|
||||
currentRecipeVersionsSelector.set([]);
|
||||
let result: RecipeVersion[] = [];
|
||||
|
||||
for (let vstr of p.versions) {
|
||||
let pure_version = vstr.split('_')[0];
|
||||
|
||||
result.push({
|
||||
display_version: pure_version,
|
||||
actual_version_name: vstr
|
||||
});
|
||||
}
|
||||
|
||||
currentRecipeVersionsSelector.set(result);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue