From 2b0a2cff46f77b263fad1fe2a8effb21b8bc1141 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 20 Jan 2022 16:48:59 +1100 Subject: [PATCH] rename console.warn to error or info depending on type --- app/sql.js | 23 +++++++++++------------ js/util_worker_tasks.js | 10 +++++----- main.js | 4 ++-- ts/data/data.ts | 4 ---- ts/state/ducks/conversations.ts | 9 +-------- 5 files changed, 19 insertions(+), 31 deletions(-) diff --git a/app/sql.js b/app/sql.js index 3f40bd16f..69f66e6d1 100644 --- a/app/sql.js +++ b/app/sql.js @@ -205,7 +205,7 @@ function getUserVersion(db) { try { return db.pragma('user_version', { simple: true }); } catch (e) { - console.warn('getUserVersion error', e); + console.error('getUserVersion error', e); return 0; } } @@ -300,9 +300,9 @@ function vacuumDatabase(db) { throw new Error('vacuum: db is not initialized'); } console.time('vaccumming db'); - console.warn('Vacuuming DB. This might take a while.'); + console.info('Vacuuming DB. This might take a while.'); db.exec('VACUUM;'); - console.warn('Vacuuming DB Finished'); + console.info('Vacuuming DB Finished'); console.timeEnd('vaccumming db'); } @@ -2068,7 +2068,7 @@ function saveSeenMessageHash(data) { hash, }); } catch (e) { - console.warn('saveSeenMessageHash failed:', e); + console.error('saveSeenMessageHash failed:', e.message); } } @@ -2271,7 +2271,7 @@ function getMessagesByConversation(conversationId, { messageId = null } = {}) { return map(rows, row => jsonToObject(row.json)); } - console.warn( + console.info( `getMessagesByConversation: Could not find messageId ${messageId} in db with conversationId: ${conversationId}. Just fetching the convo as usual.` ); } @@ -3019,7 +3019,7 @@ function updateExistingClosedGroupV1ToClosedGroupV2(db) { }; addClosedGroupEncryptionKeyPair(groupId, keyPair, db); } catch (e) { - console.warn(e); + console.error(e); } }); } @@ -3171,7 +3171,7 @@ function removeOneOpenGroupV1Message() { if (toRemoveCount <= 0) { return 0; } - console.warn('left opengroupv1 message to remove: ', toRemoveCount); + console.info('left opengroupv1 message to remove: ', toRemoveCount); const rowMessageIds = globalInstance .prepare( `SELECT id from ${MESSAGES_TABLE} WHERE conversationId LIKE 'publicChat:1@%' ORDER BY id LIMIT 1;` @@ -3237,8 +3237,8 @@ function fillWithTestData(numConvosToAdd, numMsgsToAdd) { 'count(*)' ]; - console.warn('==== fillWithTestData ===='); - console.warn({ + console.info('==== fillWithTestData ===='); + console.info({ convoBeforeCount, msgBeforeCount, convoToAdd: numConvosToAdd, @@ -3264,7 +3264,6 @@ function fillWithTestData(numConvosToAdd, numMsgsToAdd) { // eslint-disable-next-line no-empty } catch (e) {} } - console.warn('convosIdsAdded', convosIdsAdded); // eslint-disable-next-line no-plusplus for (let index = 0; index < numMsgsToAdd; index++) { const activeAt = Date.now() - index; @@ -3308,7 +3307,7 @@ function fillWithTestData(numConvosToAdd, numMsgsToAdd) { saveMessage(msgObjToAdd); // eslint-disable-next-line no-empty } catch (e) { - console.warn(e); + console.error(e); } } @@ -3320,6 +3319,6 @@ function fillWithTestData(numConvosToAdd, numMsgsToAdd) { 'count(*)' ]; - console.warn({ convoAfterCount, msgAfterCount }); + console.info({ convoAfterCount, msgAfterCount }); return convosIdsAdded; } diff --git a/js/util_worker_tasks.js b/js/util_worker_tasks.js index 203a4e29f..bf6f98649 100644 --- a/js/util_worker_tasks.js +++ b/js/util_worker_tasks.js @@ -86,13 +86,13 @@ async function verifySignature(senderPubKey, messageBase64, signatureBase64) { signature ); if (verifyRet) { - console.warn('Invalid signature'); + console.error('Invalid signature'); return false; } return true; } catch (e) { - console.warn('verifySignature got an error:', e); + console.error('verifySignature got an error:', e); return false; } } @@ -156,7 +156,7 @@ async function encryptForPubkey(pubkeyX25519str, payloadBytes) { return { ciphertext, symmetricKey, ephemeralKey: ephemeral.pubKey }; } catch (e) { - console.warn('encryptForPubkey got an error:', e); + console.error('encryptForPubkey got an error:', e); return null; } } @@ -229,7 +229,7 @@ async function decryptAttachmentBuffer(encryptingKey, bufferIn) { return messageTag.message; } } catch (e) { - console.warn('Failed to load the file as an encrypted one', e); + console.error('Failed to load the file as an encrypted one', e); } return new Uint8Array(); } @@ -257,7 +257,7 @@ async function encryptAttachmentBuffer(encryptingKey, bufferIn) { return { encryptedBufferWithHeader, header }; } catch (e) { - console.warn('encryptAttachmentBuffer error: ', e); + console.error('encryptAttachmentBuffer error: ', e); return null; } diff --git a/main.js b/main.js index f3fa22e80..6bb540edf 100644 --- a/main.js +++ b/main.js @@ -663,12 +663,12 @@ async function removeDB() { await sql.removeDB(userDir); try { - console.warn('Remove DB: removing.', userDir); + console.error('Remove DB: removing.', userDir); userConfig.remove(); ephemeralConfig.remove(); } catch (e) { - console.warn('Remove DB: Failed to remove configs.', e); + console.error('Remove DB: Failed to remove configs.', e); } } diff --git a/ts/data/data.ts b/ts/data/data.ts index 24ac526d1..e51db9f59 100644 --- a/ts/data/data.ts +++ b/ts/data/data.ts @@ -764,7 +764,6 @@ export async function getMessagesByConversation( message.skipTimerInit = skipTimerInit; } } - console.warn(`messages length got: ${messages.length} for ${conversationId}:${messageId}`); return new MessageCollection(messages); } @@ -1029,9 +1028,6 @@ export async function fillWithTestData(convs: number, msgs: number) { } for (let msgsAddedCount = 0; msgsAddedCount < msgs; msgsAddedCount++) { - if (msgsAddedCount % 100 === 0) { - console.warn(msgsAddedCount); - } // tslint:disable: insecure-random const convoToChoose = newConvos[Math.floor(Math.random() * newConvos.length)]; await convoToChoose.addSingleMessage({ diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 1df9df010..efbc31222 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -873,7 +873,6 @@ export async function openConversationWithMessages(args: { messageId: string | null; }) { const { conversationKey, messageId } = args; - console.warn('openConversationWithMessages', conversationKey); const firstUnreadIdOnOpen = await getFirstUnreadMessageIdInConversation(conversationKey); const initialMessages = await getMessages({ @@ -890,23 +889,17 @@ export async function openConversationWithMessages(args: { ); } -export async function openConversationOnQuoteClick(args: { +export async function openConversationToSpecificMessage(args: { conversationKey: string; messageIdToNavigateTo: string; }) { const { conversationKey, messageIdToNavigateTo } = args; - console.warn('openConversationOnQuoteClick', { conversationKey, messageIdToNavigateTo }); const messagesAroundThisMessage = await getMessages({ conversationKey, messageId: messageIdToNavigateTo, }); - console.warn( - 'position of navigate to message is ', - messagesAroundThisMessage.findIndex(m => m.propsForMessage.id === messageIdToNavigateTo) - ); - window.inboxStore?.dispatch( actions.navigateInConversationToMessageId({ conversationKey,