feat: show price (WIP edit)

- fix: adb tcp connection unstable retry
- fix: recipe not show by undefined machine status

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-05-18 09:49:09 +07:00
parent 60424ebe5a
commit 3b70cc9fe8
8 changed files with 269 additions and 48 deletions

View file

@ -3,6 +3,7 @@ import { addNotification, notiStore } from '../stores/noti';
import {
currentRecipeVersionsSelector,
materialFromServerQuery,
priceRecipeData,
recipeData,
recipeDataError,
recipeLoading,
@ -16,6 +17,9 @@ import { auth } from '../client/firebase';
import { type RecipeVersion } from '$lib/models/recipe_version.model';
import { goto } from '$app/navigation';
import { socketAlreadySendHeartbeat, socketConnectionOfflineCount } from '../stores/websocketStore';
import type { RecipePrice } from '$lib/models/price.model';
import { sendMessage } from './ws_messageSender';
import { auth as authStore } from '../stores/auth';
export const messages = writable<string[]>([]);
@ -111,6 +115,32 @@ const handlers: Record<string, (payload: any) => void> = {
// console.log('ending stream');
buildOverviewFromServer();
let current_meta = get(recipeStreamMeta);
let curr_user = get(authStore);
let user_info: any;
if (curr_user) {
user_info = {
displayName: curr_user.displayName,
email: curr_user.email,
uid: curr_user.uid
};
}
// send next chain message
sendMessage({
type: 'price',
payload: {
action: {
View: 'sa=all'
},
country: current_meta?.country ?? '',
parameters: '',
user_info
}
});
},
stream_data_extra: (p) => {
// extended data from server, may be extra infos
@ -214,7 +244,16 @@ const handlers: Record<string, (payload: any) => void> = {
let status = p.status;
let to = p.to;
let content = p.content ?? [];
let content: RecipePrice[] = p.content ?? [];
console.log('get price length: ', content.length);
let current_price = get(priceRecipeData);
for (const c of content) {
current_price[c.ProductCode] = c.NewPrice + (c.StringParam ? `,${c.StringParam}` : '');
}
priceRecipeData.set(current_price);
},
heartbeat: (p) => {
socketConnectionOfflineCount.set(0);