change: remove loading while request recipe
progress: WIP editing flow Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
parent
3388eca2fe
commit
e9192c8607
24 changed files with 538 additions and 81 deletions
|
|
@ -35,7 +35,7 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
|
||||
if (stream_id) {
|
||||
addNotification('INFO:Start streaming data');
|
||||
recipeLoading.set(true);
|
||||
// recipeLoading.set(true);
|
||||
recipeStreamMeta.set({
|
||||
id: stream_id,
|
||||
total_size: total_size,
|
||||
|
|
@ -82,6 +82,7 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
if (percent == 100) {
|
||||
addNotification(`INFO:Current progress ${percent}%`);
|
||||
}
|
||||
buildOverviewFromServer();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ export function sendMessage(msg: OutMessage): boolean {
|
|||
const socket = get(socketStore);
|
||||
const data = JSON.stringify(msg);
|
||||
|
||||
// console.log('try sending ', data);
|
||||
|
||||
if (!socket || socket.readyState !== WebSocket.OPEN) {
|
||||
console.warn('WebSocket not connected, put to queue');
|
||||
|
||||
|
|
|
|||
|
|
@ -7,49 +7,56 @@ import { auth } from '../client/firebase';
|
|||
import { addNotification } from './noti';
|
||||
|
||||
let socket: WebSocket | null = null;
|
||||
const ENABLE_WS_DEBUG: boolean = false;
|
||||
|
||||
export const socketStore = writable<WebSocket | null>(null);
|
||||
|
||||
export function connectToWebsocket() {
|
||||
if (browser) {
|
||||
console.log('connecting to ', env.PUBLIC_WSS);
|
||||
socket = new WebSocket(`${env.PUBLIC_WSS}`);
|
||||
// console.log('connecting to ', env.PUBLIC_WSS);
|
||||
try {
|
||||
socket = new WebSocket(`${env.PUBLIC_WSS}`);
|
||||
|
||||
socket.addEventListener('open', () => {
|
||||
socketStore.set(socket);
|
||||
addNotification('INFO:Connected!');
|
||||
socket.addEventListener('open', () => {
|
||||
socketStore.set(socket);
|
||||
addNotification('INFO:Connected!');
|
||||
|
||||
// recover messages on connect, flushing
|
||||
while (get(msgQueue).length) {
|
||||
let queue = get(msgQueue);
|
||||
let current = queue.shift();
|
||||
if (current && socket) {
|
||||
socket.send(current);
|
||||
// set next
|
||||
msgQueue.set(queue);
|
||||
// recover messages on connect, flushing
|
||||
while (get(msgQueue).length) {
|
||||
let queue = get(msgQueue);
|
||||
let current = queue.shift();
|
||||
if (current && socket) {
|
||||
socket.send(current);
|
||||
// set next
|
||||
msgQueue.set(queue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener('message', (event) => {
|
||||
handleIncomingMessages(event.data);
|
||||
});
|
||||
|
||||
socket.addEventListener('close', () => {
|
||||
socketStore.set(null);
|
||||
socket = null;
|
||||
|
||||
if (auth.currentUser) {
|
||||
// console.log('try reconnect websocket ...');
|
||||
// retry again
|
||||
setTimeout(() => connectToWebsocket(), 5000);
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener('error', (e) => {
|
||||
// console.log('WebSocket error: ', e);
|
||||
socketStore.set(null);
|
||||
});
|
||||
} catch (socket_error: any) {
|
||||
if (ENABLE_WS_DEBUG) {
|
||||
console.error('WS_ERR', socket_error);
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener('message', (event) => {
|
||||
handleIncomingMessages(event.data);
|
||||
});
|
||||
|
||||
socket.addEventListener('close', () => {
|
||||
socketStore.set(null);
|
||||
socket = null;
|
||||
|
||||
if (auth.currentUser) {
|
||||
console.log('try reconnect websocket ...');
|
||||
// retry again
|
||||
setTimeout(() => connectToWebsocket(), 5000);
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener('error', (e) => {
|
||||
console.log('WebSocket error: ', e);
|
||||
socketStore.set(null);
|
||||
});
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (socket?.readyState === WebSocket.OPEN) {
|
||||
|
|
|
|||
|
|
@ -22,4 +22,13 @@ export type OutMessage =
|
|||
permissions: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
| {
|
||||
type: 'log_report';
|
||||
payload: {
|
||||
user: string;
|
||||
action: string;
|
||||
country: string;
|
||||
values: any;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue