Removing a few console.log...

This commit is contained in:
Eric van der Vlist 2023-02-12 14:10:56 +01:00
parent 5a5931dbcd
commit 4502162a36
4 changed files with 54 additions and 54 deletions

View File

@ -77,7 +77,7 @@ export const watchDbLegacy = async () => {
globalThis.sync globalThis.sync
.on('change', function (info) { .on('change', function (info) {
// handle change // handle change
console.log({ caller: 'Sync / change', info }); // console.log({ caller: 'Sync / change', info });
if (info.direction === 'push') { if (info.direction === 'push') {
setSyncState({ ...syncState(), lastSeq: info.change.last_seq }); setSyncState({ ...syncState(), lastSeq: info.change.last_seq });
} }
@ -85,12 +85,12 @@ export const watchDbLegacy = async () => {
.on('paused', function (err) { .on('paused', function (err) {
// replication paused (e.g. replication up to date, user went offline) // replication paused (e.g. replication up to date, user went offline)
setSyncState({ ...syncState(), paused: true }); setSyncState({ ...syncState(), paused: true });
console.log({ caller: 'Sync / paused', err }); // console.log({ caller: 'Sync / paused', err });
}) })
.on('active', function () { .on('active', function () {
// replicate resumed (e.g. new changes replicating, user went back online) // replicate resumed (e.g. new changes replicating, user went back online)
setSyncState({ ...syncState(), paused: false }); setSyncState({ ...syncState(), paused: false });
console.log({ caller: 'Sync / active' }); // console.log({ caller: 'Sync / active' });
}) })
.on('denied', function (err) { .on('denied', function (err) {
// a document failed to replicate (e.g. due to permissions) // a document failed to replicate (e.g. due to permissions)

View File

@ -43,7 +43,7 @@ for (const property in methods) {
} }
const changeHandler = async (change: any) => { const changeHandler = async (change: any) => {
console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches }); // console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches });
const { id } = change; const { id } = change;
if (!globalThis.watches) { if (!globalThis.watches) {
globalThis.watches = new Map(); globalThis.watches = new Map();
@ -55,22 +55,22 @@ const changeHandler = async (change: any) => {
tokens.splice(-1); tokens.splice(-1);
} }
const parentId = tokens.join('/'); const parentId = tokens.join('/');
console.log({ // console.log({
caller: 'ChangeHandler', // caller: 'ChangeHandler',
change, // change,
watches: globalThis.watches, // watches: globalThis.watches,
parentId, // parentId,
}); // });
if (parentId === 'gpx') { if (parentId === 'gpx') {
const gpxes = await getAllGpxes(); const gpxes = await getAllGpxes();
console.log({ caller: 'changeHandler / gpxes', gpxes, id }); // console.log({ caller: 'changeHandler / gpxes', gpxes, id });
if (!gpxes.includes(id)) { if (!gpxes.includes(id)) {
await put( await put(
parentId, parentId,
`idx-${parentId}`, `idx-${parentId}`,
(doc) => { (doc) => {
console.log({ caller: 'changeHandler / gpxes', doc }); // console.log({ caller: 'changeHandler / gpxes', doc });
doc.push(id); doc.push(id);
doc.reverse().sort().reverse(); doc.reverse().sort().reverse();
return doc; return doc;
@ -89,23 +89,23 @@ const changeHandler = async (change: any) => {
export default changeHandler; export default changeHandler;
export const getAndWatch = async (params: any) => { export const getAndWatch = async (params: any) => {
console.log({ // console.log({
caller: 'ChangeHandler / getAndWatch', // caller: 'ChangeHandler / getAndWatch',
params, // params,
watches: globalThis.watches, // watches: globalThis.watches,
}); // });
const { method, _dispatchId, id, ...otherParams } = params; const { method, _dispatchId, id, ...otherParams } = params;
if (!globalThis.watches) { if (!globalThis.watches) {
globalThis.watches = new Map(); globalThis.watches = new Map();
} }
globalThis.watches.set(id, params); globalThis.watches.set(id, params);
const returnValue = await methods[<keyof typeof methods>method](params); const returnValue = await methods[<keyof typeof methods>method](params);
console.log({ // console.log({
caller: 'ChangeHandler / getAndWatch', // caller: 'ChangeHandler / getAndWatch',
params, // params,
returnValue, // returnValue,
watches: globalThis.watches, // watches: globalThis.watches,
}); // });
return returnValue; return returnValue;
}; };

View File

@ -19,12 +19,12 @@ export const init = () => {
worker.onmessage = (event: any) => { worker.onmessage = (event: any) => {
const { id, payload } = event.data; const { id, payload } = event.data;
console.log({ // console.log({
caller: 'dispatcher-main / message received', // caller: 'dispatcher-main / message received',
id, // id,
payload, // payload,
dispatcherQueue: JSON.parse(JSON.stringify(dispatcherQueue)), // dispatcherQueue: JSON.parse(JSON.stringify(dispatcherQueue)),
}); // });
dispatcherQueue.queue.get(id).callBack(null, payload, id); dispatcherQueue.queue.get(id).callBack(null, payload, id);
if (!dispatcherQueue.queue.get(id).live) { if (!dispatcherQueue.queue.get(id).live) {
cancelDispatch(id); cancelDispatch(id);
@ -36,11 +36,11 @@ const [watchDbStatus] = createWorkerSignal({
provider: 'watchDb', provider: 'watchDb',
}); });
const dbReady = () => { const dbReady = () => {
console.log({ // console.log({
caller: 'dispatcher-main / waiting', // caller: 'dispatcher-main / waiting',
dbStatus: watchDbStatus(), // dbStatus: watchDbStatus(),
dbReady: watchDbStatus()?.opened, // dbReady: watchDbStatus()?.opened,
}); // });
return watchDbStatus()?.opened; return watchDbStatus()?.opened;
}; };
@ -49,7 +49,7 @@ const dispatch = async (
callBack?: (error: any, result: any, id?: number | undefined) => void, callBack?: (error: any, result: any, id?: number | undefined) => void,
live?: boolean live?: boolean
) => { ) => {
console.log({ caller: 'dispatcher-main / dispatch', payload, callBack }); // console.log({ caller: 'dispatcher-main / dispatch', payload, callBack });
if (worker === undefined) { if (worker === undefined) {
init(); init();
} }
@ -73,11 +73,11 @@ const dispatch = async (
payload: payload, payload: payload,
}; };
worker.postMessage(message); worker.postMessage(message);
console.log({ // console.log({
caller: 'dispatcher-main / message sent', // caller: 'dispatcher-main / message sent',
message, // message,
dispatcherQueue, // dispatcherQueue,
}); // });
}; };
export const cancelDispatch = (id: number) => { export const cancelDispatch = (id: number) => {

View File

@ -67,35 +67,35 @@ onmessage = async function (e) {
putAccount, putAccount,
}; };
console.log({ caller: 'dispatcher-worker / onmessage', e }); // console.log({ caller: 'dispatcher-worker / onmessage', e });
initDb(); initDb();
await until(() => globalThis.dbReady, 100); // Wait until databases have been initialized in this worker await until(() => globalThis.dbReady, 100); // Wait until databases have been initialized in this worker
const { id, payload } = e.data; const { id, payload } = e.data;
var returnValue: any = 'unknownAction'; var returnValue: any = 'unknownAction';
if (payload.action in actions) { if (payload.action in actions) {
console.log({ // console.log({
caller: 'dispatcher-worker / awaiting', // caller: 'dispatcher-worker / awaiting',
id, // id,
payload, // payload,
dbReady: globalThis.dbReady, // dbReady: globalThis.dbReady,
}); // });
returnValue = await actions[<keyof typeof actions>payload.action]({ returnValue = await actions[<keyof typeof actions>payload.action]({
...payload.params, ...payload.params,
_dispatchId: id, _dispatchId: id,
}); });
} }
postMessage({ id: id, payload: returnValue }); postMessage({ id: id, payload: returnValue });
console.log({ // console.log({
caller: 'dispatcher-worker / response sent', // caller: 'dispatcher-worker / response sent',
id, // id,
returnValue, // returnValue,
dbReady: globalThis.dbReady, // dbReady: globalThis.dbReady,
}); // });
}; };
export const returnAgain = (id: number, returnValue: any) => { 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 }); postMessage({ id: id, payload: returnValue });
}; };