Removing a few console.log...
This commit is contained in:
parent
5a5931dbcd
commit
4502162a36
|
@ -77,7 +77,7 @@ export const watchDbLegacy = async () => {
|
|||
globalThis.sync
|
||||
.on('change', function (info) {
|
||||
// handle change
|
||||
console.log({ caller: 'Sync / change', info });
|
||||
// console.log({ caller: 'Sync / change', info });
|
||||
if (info.direction === 'push') {
|
||||
setSyncState({ ...syncState(), lastSeq: info.change.last_seq });
|
||||
}
|
||||
|
@ -85,12 +85,12 @@ export const watchDbLegacy = async () => {
|
|||
.on('paused', function (err) {
|
||||
// replication paused (e.g. replication up to date, user went offline)
|
||||
setSyncState({ ...syncState(), paused: true });
|
||||
console.log({ caller: 'Sync / paused', err });
|
||||
// console.log({ caller: 'Sync / paused', err });
|
||||
})
|
||||
.on('active', function () {
|
||||
// replicate resumed (e.g. new changes replicating, user went back online)
|
||||
setSyncState({ ...syncState(), paused: false });
|
||||
console.log({ caller: 'Sync / active' });
|
||||
// console.log({ caller: 'Sync / active' });
|
||||
})
|
||||
.on('denied', function (err) {
|
||||
// a document failed to replicate (e.g. due to permissions)
|
||||
|
|
|
@ -43,7 +43,7 @@ for (const property in methods) {
|
|||
}
|
||||
|
||||
const changeHandler = async (change: any) => {
|
||||
console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches });
|
||||
// console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches });
|
||||
const { id } = change;
|
||||
if (!globalThis.watches) {
|
||||
globalThis.watches = new Map();
|
||||
|
@ -55,22 +55,22 @@ const changeHandler = async (change: any) => {
|
|||
tokens.splice(-1);
|
||||
}
|
||||
const parentId = tokens.join('/');
|
||||
console.log({
|
||||
caller: 'ChangeHandler',
|
||||
change,
|
||||
watches: globalThis.watches,
|
||||
parentId,
|
||||
});
|
||||
// console.log({
|
||||
// caller: 'ChangeHandler',
|
||||
// change,
|
||||
// watches: globalThis.watches,
|
||||
// parentId,
|
||||
// });
|
||||
|
||||
if (parentId === 'gpx') {
|
||||
const gpxes = await getAllGpxes();
|
||||
console.log({ caller: 'changeHandler / gpxes', gpxes, id });
|
||||
// console.log({ caller: 'changeHandler / gpxes', gpxes, id });
|
||||
if (!gpxes.includes(id)) {
|
||||
await put(
|
||||
parentId,
|
||||
`idx-${parentId}`,
|
||||
(doc) => {
|
||||
console.log({ caller: 'changeHandler / gpxes', doc });
|
||||
// console.log({ caller: 'changeHandler / gpxes', doc });
|
||||
doc.push(id);
|
||||
doc.reverse().sort().reverse();
|
||||
return doc;
|
||||
|
@ -89,23 +89,23 @@ const changeHandler = async (change: any) => {
|
|||
export default changeHandler;
|
||||
|
||||
export const getAndWatch = async (params: any) => {
|
||||
console.log({
|
||||
caller: 'ChangeHandler / getAndWatch',
|
||||
params,
|
||||
watches: globalThis.watches,
|
||||
});
|
||||
// console.log({
|
||||
// caller: 'ChangeHandler / getAndWatch',
|
||||
// params,
|
||||
// watches: globalThis.watches,
|
||||
// });
|
||||
const { method, _dispatchId, id, ...otherParams } = params;
|
||||
if (!globalThis.watches) {
|
||||
globalThis.watches = new Map();
|
||||
}
|
||||
globalThis.watches.set(id, params);
|
||||
const returnValue = await methods[<keyof typeof methods>method](params);
|
||||
console.log({
|
||||
caller: 'ChangeHandler / getAndWatch',
|
||||
params,
|
||||
returnValue,
|
||||
watches: globalThis.watches,
|
||||
});
|
||||
// console.log({
|
||||
// caller: 'ChangeHandler / getAndWatch',
|
||||
// params,
|
||||
// returnValue,
|
||||
// watches: globalThis.watches,
|
||||
// });
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@ export const init = () => {
|
|||
|
||||
worker.onmessage = (event: any) => {
|
||||
const { id, payload } = event.data;
|
||||
console.log({
|
||||
caller: 'dispatcher-main / message received',
|
||||
id,
|
||||
payload,
|
||||
dispatcherQueue: JSON.parse(JSON.stringify(dispatcherQueue)),
|
||||
});
|
||||
// console.log({
|
||||
// caller: 'dispatcher-main / message received',
|
||||
// id,
|
||||
// payload,
|
||||
// dispatcherQueue: JSON.parse(JSON.stringify(dispatcherQueue)),
|
||||
// });
|
||||
dispatcherQueue.queue.get(id).callBack(null, payload, id);
|
||||
if (!dispatcherQueue.queue.get(id).live) {
|
||||
cancelDispatch(id);
|
||||
|
@ -36,11 +36,11 @@ const [watchDbStatus] = createWorkerSignal({
|
|||
provider: 'watchDb',
|
||||
});
|
||||
const dbReady = () => {
|
||||
console.log({
|
||||
caller: 'dispatcher-main / waiting',
|
||||
dbStatus: watchDbStatus(),
|
||||
dbReady: watchDbStatus()?.opened,
|
||||
});
|
||||
// console.log({
|
||||
// caller: 'dispatcher-main / waiting',
|
||||
// dbStatus: watchDbStatus(),
|
||||
// dbReady: watchDbStatus()?.opened,
|
||||
// });
|
||||
return watchDbStatus()?.opened;
|
||||
};
|
||||
|
||||
|
@ -49,7 +49,7 @@ const dispatch = async (
|
|||
callBack?: (error: any, result: any, id?: number | undefined) => void,
|
||||
live?: boolean
|
||||
) => {
|
||||
console.log({ caller: 'dispatcher-main / dispatch', payload, callBack });
|
||||
// console.log({ caller: 'dispatcher-main / dispatch', payload, callBack });
|
||||
if (worker === undefined) {
|
||||
init();
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ const dispatch = async (
|
|||
payload: payload,
|
||||
};
|
||||
worker.postMessage(message);
|
||||
console.log({
|
||||
caller: 'dispatcher-main / message sent',
|
||||
message,
|
||||
dispatcherQueue,
|
||||
});
|
||||
// console.log({
|
||||
// caller: 'dispatcher-main / message sent',
|
||||
// message,
|
||||
// dispatcherQueue,
|
||||
// });
|
||||
};
|
||||
|
||||
export const cancelDispatch = (id: number) => {
|
||||
|
|
|
@ -67,35 +67,35 @@ onmessage = async function (e) {
|
|||
putAccount,
|
||||
};
|
||||
|
||||
console.log({ caller: 'dispatcher-worker / onmessage', e });
|
||||
// console.log({ caller: 'dispatcher-worker / onmessage', e });
|
||||
initDb();
|
||||
|
||||
await until(() => globalThis.dbReady, 100); // Wait until databases have been initialized in this worker
|
||||
const { id, payload } = e.data;
|
||||
var returnValue: any = 'unknownAction';
|
||||
if (payload.action in actions) {
|
||||
console.log({
|
||||
caller: 'dispatcher-worker / awaiting',
|
||||
id,
|
||||
payload,
|
||||
dbReady: globalThis.dbReady,
|
||||
});
|
||||
// console.log({
|
||||
// caller: 'dispatcher-worker / awaiting',
|
||||
// id,
|
||||
// payload,
|
||||
// dbReady: globalThis.dbReady,
|
||||
// });
|
||||
returnValue = await actions[<keyof typeof actions>payload.action]({
|
||||
...payload.params,
|
||||
_dispatchId: id,
|
||||
});
|
||||
}
|
||||
postMessage({ id: id, payload: returnValue });
|
||||
console.log({
|
||||
caller: 'dispatcher-worker / response sent',
|
||||
id,
|
||||
returnValue,
|
||||
dbReady: globalThis.dbReady,
|
||||
});
|
||||
// console.log({
|
||||
// caller: 'dispatcher-worker / response sent',
|
||||
// id,
|
||||
// returnValue,
|
||||
// dbReady: globalThis.dbReady,
|
||||
// });
|
||||
};
|
||||
|
||||
export const returnAgain = (id: number, returnValue: any) => {
|
||||
console.log({ caller: 'dispatcher-worker / returnAgain', id, returnValue });
|
||||
// console.log({ caller: 'dispatcher-worker / returnAgain', id, returnValue });
|
||||
postMessage({ id: id, payload: returnValue });
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue