From d982bab66b4e2794a64158d877b6e78afa8d0c0f Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 24 May 2021 16:04:05 +1000 Subject: [PATCH] fix lint for js files (no ?.) --- js/background.js | 42 ++++++++++---------- js/database.js | 10 ++--- js/delivery_receipts.js | 4 +- js/expiring_messages.js | 10 ++--- js/legacy_storage.js | 2 +- js/logging.js | 4 +- js/modules/backup.js | 56 +++++++++++++-------------- js/modules/debuglogs.js | 2 +- js/modules/loki_app_dot_net_api.js | 8 ++-- js/modules/util_worker_interface.js | 6 +-- js/notifications.js | 8 ++-- js/read_receipts.js | 6 +-- js/read_syncs.js | 9 ++--- js/reliable_trigger.js | 2 +- js/storage.js | 6 +-- js/views/debug_log_view.js | 6 +-- js/views/import_view.js | 4 +- js/views/session_registration_view.js | 2 +- js/views/update_group_dialog_view.js | 4 +- libtextsecure/message_receiver.js | 8 ++-- libtextsecure/protobufs.js | 4 +- libtextsecure/task_with_timeout.js | 4 +- 22 files changed, 102 insertions(+), 105 deletions(-) diff --git a/js/background.js b/js/background.js index 0bda24e7f..04a23597d 100644 --- a/js/background.js +++ b/js/background.js @@ -72,10 +72,10 @@ // Implicitly used in `indexeddb-backbonejs-adapter`: // https://github.com/signalapp/Signal-Desktop/blob/4033a9f8137e62ed286170ed5d4941982b1d3a64/components/indexeddb-backbonejs-adapter/backbone-indexeddb.js#L569 window.onInvalidStateError = error => - window?.log?.error(error && error.stack ? error.stack : error); + window.log.error(error && error.stack ? error.stack : error); - window?.log?.info('background page reloaded'); - window?.log?.info('environment:', window.getEnvironment()); + window.log.info('background page reloaded'); + window.log.info('environment:', window.getEnvironment()); const restartReason = localStorage.getItem('restart-reason'); if (restartReason === 'unlink') { @@ -97,7 +97,7 @@ Whisper.events._events ? !!Whisper.events._events[eventName] : false; const cancelInitializationMessage = Views.Initialization.setMessage(); - window?.log?.info('Storage fetch'); + window.log.info('Storage fetch'); storage.fetch(); let specialConvInited = false; @@ -216,7 +216,7 @@ await storage.put('version', currentVersion); if (newVersion) { - window?.log?.info(`New version detected: ${currentVersion}; previous: ${lastVersion}`); + window.log.info(`New version detected: ${currentVersion}; previous: ${lastVersion}`); await window.Signal.Data.cleanupOrphanedAttachments(); @@ -237,7 +237,7 @@ BlockedNumberController.load(), ]); } catch (error) { - window?.log?.error( + window.log.error( 'background.js: ConversationController failed to load:', error && error.stack ? error.stack : error ); @@ -284,7 +284,7 @@ manageExpiringData(); window.dispatchEvent(new Event('storage_ready')); - window?.log?.info('Cleanup: starting...'); + window.log.info('Cleanup: starting...'); const results = await Promise.all([window.Signal.Data.getOutgoingWithoutExpiresAt()]); @@ -294,7 +294,7 @@ [] ); - window?.log?.info(`Cleanup: Found ${messagesForCleanup.length} messages for cleanup`); + window.log.info(`Cleanup: Found ${messagesForCleanup.length} messages for cleanup`); await Promise.all( messagesForCleanup.map(async message => { const delivered = message.get('delivered'); @@ -306,21 +306,21 @@ } if (delivered) { - window?.log?.info(`Cleanup: Starting timer for delivered message ${sentAt}`); + window.log.info(`Cleanup: Starting timer for delivered message ${sentAt}`); message.set('expirationStartTimestamp', expirationStartTimestamp || sentAt); await message.setToExpire(); return; } - window?.log?.info(`Cleanup: Deleting unsent message ${sentAt}`); + window.log.info(`Cleanup: Deleting unsent message ${sentAt}`); await window.Signal.Data.removeMessage(message.id); }) ); - window?.log?.info('Cleanup: complete'); + window.log.info('Cleanup: complete'); - window?.log?.info('listening for registration events'); + window.log.info('listening for registration events'); Whisper.events.on('registration_done', async () => { - window?.log?.info('handling registration event'); + window.log.info('handling registration event'); // Disable link previews as default per Kee storage.onready(async () => { @@ -339,7 +339,7 @@ Whisper.ExpiringMessagesListener.init(Whisper.events); if (Whisper.Import.isIncomplete()) { - window?.log?.info('Import was interrupted, showing import error screen'); + window.log.info('Import was interrupted, showing import error screen'); appView.openImporter(); } else if ( Whisper.Registration.isDone() && @@ -491,7 +491,7 @@ window.libsession.Utils.UserUtils.setLastProfileUpdateTimestamp(Date.now()); await window.libsession.Utils.SyncUtils.forceSyncConfigurationNowIfNeeded(true); } catch (error) { - window?.log?.error( + window.log.error( 'showEditProfileDialog Error ensuring that image is properly sized:', error && error.stack ? error.stack : error ); @@ -673,7 +673,7 @@ let disconnectTimer = null; function onOffline() { - window?.log?.info('offline'); + window.log.info('offline'); window.removeEventListener('offline', onOffline); window.addEventListener('online', onOnline); @@ -685,13 +685,13 @@ } function onOnline() { - window?.log?.info('online'); + window.log.info('online'); window.removeEventListener('online', onOnline); window.addEventListener('offline', onOffline); if (disconnectTimer) { - window?.log?.warn('Already online. Had a blip in online/offline status.'); + window.log.warn('Already online. Had a blip in online/offline status.'); clearTimeout(disconnectTimer); disconnectTimer = null; return; @@ -705,7 +705,7 @@ } async function disconnect() { - window?.log?.info('disconnect'); + window.log.info('disconnect'); // Clear timer, since we're only called when the timer is expired disconnectTimer = null; @@ -718,14 +718,14 @@ let connectCount = 0; async function connect(firstRun) { - window?.log?.info('connect'); + window.log.info('connect'); // Bootstrap our online/offline detection, only the first time we connect if (connectCount === 0 && navigator.onLine) { window.addEventListener('offline', onOffline); } if (connectCount === 0 && !navigator.onLine) { - window?.log?.warn('Starting up offline; will connect when we have network access'); + window.log.warn('Starting up offline; will connect when we have network access'); window.addEventListener('online', onOnline); onEmpty(); // this ensures that the loading screen is dismissed return; diff --git a/js/database.js b/js/database.js index 45e05739a..d88b4d904 100644 --- a/js/database.js +++ b/js/database.js @@ -13,7 +13,7 @@ window.Whisper.Database.nolog = true; Whisper.Database.handleDOMException = (prefix, error, reject) => { - window?.log?.error( + window.log.error( `${prefix}:`, error && error.name, error && error.message, @@ -25,12 +25,12 @@ function clearStores(db, names) { return new Promise((resolve, reject) => { const storeNames = names || db.objectStoreNames; - window?.log?.info('Clearing these indexeddb stores:', storeNames); + window.log.info('Clearing these indexeddb stores:', storeNames); const transaction = db.transaction(storeNames, 'readwrite'); let finished = false; const finish = via => { - window?.log?.info('clearing all stores done via', via); + window.log.info('clearing all stores done via', via); if (finished) { resolve(); } @@ -55,10 +55,10 @@ request.onsuccess = () => { count += 1; - window?.log?.info('Done clearing store', storeName); + window.log.info('Done clearing store', storeName); if (count >= storeNames.length) { - window?.log?.info('Done clearing indexeddb stores'); + window.log.info('Done clearing indexeddb stores'); finish('clears complete'); } }; diff --git a/js/delivery_receipts.js b/js/delivery_receipts.js index dc03d44a9..d24a49207 100644 --- a/js/delivery_receipts.js +++ b/js/delivery_receipts.js @@ -61,7 +61,7 @@ const message = await this.getTargetMessage(receipt.get('source'), messages); if (!message) { - window?.log?.info( + window.log.info( 'No message for delivery receipt', receipt.get('source'), receipt.get('timestamp') @@ -94,7 +94,7 @@ this.remove(receipt); } catch (error) { - window?.log?.error( + window.log.error( 'DeliveryReceipts.onReceipt error:', error && error.stack ? error.stack : error ); diff --git a/js/expiring_messages.js b/js/expiring_messages.js index 675d52321..2327f60ec 100644 --- a/js/expiring_messages.js +++ b/js/expiring_messages.js @@ -15,14 +15,14 @@ async function destroyExpiredMessages() { try { - window?.log?.info('destroyExpiredMessages: Loading messages...'); + window.log.info('destroyExpiredMessages: Loading messages...'); const messages = await window.Signal.Data.getExpiredMessages(); await Promise.all( messages.map(async fromDB => { const message = getMessageController().register(fromDB.id, fromDB); - window?.log?.info('Message expired', { + window.log.info('Message expired', { sentAt: message.get('sent_at'), }); @@ -42,13 +42,13 @@ }) ); } catch (error) { - window?.log?.error( + window.log.error( 'destroyExpiredMessages: Error deleting expired messages', error && error.stack ? error.stack : error ); } - window?.log?.info('destroyExpiredMessages: complete'); + window.log.info('destroyExpiredMessages: complete'); checkExpiringMessages(); } @@ -64,7 +64,7 @@ const expiresAt = next.get('expires_at'); Whisper.ExpiringMessagesListener.nextExpiration = expiresAt; - window?.log?.info('next message expires', new Date(expiresAt).toISOString()); + window.log.info('next message expires', new Date(expiresAt).toISOString()); let wait = expiresAt - Date.now(); diff --git a/js/legacy_storage.js b/js/legacy_storage.js index 131150903..c454ea590 100644 --- a/js/legacy_storage.js +++ b/js/legacy_storage.js @@ -31,7 +31,7 @@ throw new Error('Tried to store undefined'); } if (!ready) { - window?.log?.warn('Called storage.put before storage is ready. key:', key); + window.log.warn('Called storage.put before storage is ready. key:', key); } const item = items.add({ id: key, value }, { merge: true }); return new Promise((resolve, reject) => { diff --git a/js/logging.js b/js/logging.js index d1243aec2..0c7cb1186 100644 --- a/js/logging.js +++ b/js/logging.js @@ -132,11 +132,11 @@ window.log = { window.onerror = (message, script, line, col, error) => { const errorInfo = error && error.stack ? error.stack : JSON.stringify(error); - window?.log?.error(`Top-level unhandled error: ${errorInfo}`); + window.log.error(`Top-level unhandled error: ${errorInfo}`); }; window.addEventListener('unhandledrejection', rejectionEvent => { const error = rejectionEvent.reason; const errorInfo = error && error.stack ? error.stack : error; - window?.log?.error('Top-level unhandled promise rejection:', errorInfo); + window.log.error('Top-level unhandled promise rejection:', errorInfo); }); diff --git a/js/modules/backup.js b/js/modules/backup.js index 70787a56e..59cca4034 100644 --- a/js/modules/backup.js +++ b/js/modules/backup.js @@ -142,7 +142,7 @@ async function exportConversationList(fileWriter) { stream.write('"conversations": '); const conversations = await window.Signal.Data.getAllConversations(); - window?.log?.info(`Exporting ${conversations.length} conversations`); + window.log.info(`Exporting ${conversations.length} conversations`); writeArray(stream, getPlainJS(conversations)); stream.write('}'); @@ -157,11 +157,11 @@ async function importNonMessages(parent, options) { function eliminateClientConfigInBackup(data, targetPath) { const cleaned = _.pick(data, 'conversations'); - window?.log?.info('Writing configuration-free backup file back to disk'); + window.log.info('Writing configuration-free backup file back to disk'); try { fs.writeFileSync(targetPath, JSON.stringify(cleaned)); } catch (error) { - window?.log?.error('Error writing cleaned-up backup to disk: ', error.stack); + window.log.error('Error writing cleaned-up backup to disk: ', error.stack); } } @@ -192,7 +192,7 @@ async function importConversationsFromJSON(conversations, options) { await window.Signal.Data.saveConversation(migrated); } - window?.log?.info('Done importing conversations:', 'Total count:', count, 'Skipped:', skipCount); + window.log.info('Done importing conversations:', 'Total count:', count, 'Skipped:', skipCount); } async function importFromJsonString(jsonString, targetPath, options) { @@ -219,7 +219,7 @@ async function importFromJsonString(jsonString, targetPath, options) { delete importObject.sessions; delete importObject.unprocessed; - window?.log?.info('This is a light import; contacts, groups and messages only'); + window.log.info('This is a light import; contacts, groups and messages only'); } // We mutate the on-disk backup to prevent the user from importing client @@ -228,7 +228,7 @@ async function importFromJsonString(jsonString, targetPath, options) { eliminateClientConfigInBackup(importObject, targetPath); const storeNames = _.keys(importObject); - window?.log?.info('Importing to these stores:', storeNames.join(', ')); + window.log.info('Importing to these stores:', storeNames.join(', ')); // Special-case conversations key here, going to SQLCipher const { conversations } = importObject; @@ -251,11 +251,11 @@ async function importFromJsonString(jsonString, targetPath, options) { throw new Error(`importFromJsonString: Didn't have save function for store ${storeName}`); } - window?.log?.info(`Importing items for store ${storeName}`); + window.log.info(`Importing items for store ${storeName}`); const toImport = importObject[storeName]; if (!toImport || !toImport.length) { - window?.log?.info(`No items in ${storeName} store`); + window.log.info(`No items in ${storeName} store`); return; } @@ -265,11 +265,11 @@ async function importFromJsonString(jsonString, targetPath, options) { await save(toAdd); } - window?.log?.info('Done importing to store', storeName, 'Total count:', toImport.length); + window.log.info('Done importing to store', storeName, 'Total count:', toImport.length); }) ); - window?.log?.info('DB import complete'); + window.log.info('DB import complete'); return result; } @@ -380,7 +380,7 @@ async function readEncryptedAttachment(dir, attachment, name, options) { const targetPath = path.join(dir, sanitizedName); if (!fs.existsSync(targetPath)) { - window?.log?.warn(`Warning: attachment ${sanitizedName} not found`); + window.log.warn(`Warning: attachment ${sanitizedName} not found`); return; } @@ -427,7 +427,7 @@ async function writeQuoteThumbnails(quotedAttachments, options) { ) ); } catch (error) { - window?.log?.error( + window.log.error( 'writeThumbnails: error exporting conversation', name, ':', @@ -490,7 +490,7 @@ async function writeAttachments(attachments, options) { try { await Promise.all(promises); } catch (error) { - window?.log?.error( + window.log.error( 'writeAttachments: error exporting conversation', name, ':', @@ -534,7 +534,7 @@ async function writeContactAvatars(contact, options) { ) ); } catch (error) { - window?.log?.error( + window.log.error( 'writeContactAvatars: error exporting conversation', name, ':', @@ -578,7 +578,7 @@ async function writePreviews(preview, options) { ) ); } catch (error) { - window?.log?.error( + window.log.error( 'writePreviews: error exporting conversation', name, ':', @@ -593,10 +593,10 @@ async function writeEncryptedAttachment(target, source, options = {}) { if (fs.existsSync(target)) { if (newKey) { - window?.log?.info(`Deleting attachment ${filename}; key has changed`); + window.log.info(`Deleting attachment ${filename}; key has changed`); fs.unlinkSync(target); } else { - window?.log?.info(`Skipping attachment ${filename}; already exists`); + window.log.info(`Skipping attachment ${filename}; already exists`); return; } } @@ -631,7 +631,7 @@ async function exportConversation(conversation, options = {}) { throw new Error('Need a key to encrypt with!'); } - window?.log?.info('exporting conversation', name); + window.log.info('exporting conversation', name); const writer = await createFileAndWriter(dir, 'messages.json'); const stream = createOutputStream(writer); stream.write('{"messages":['); @@ -804,7 +804,7 @@ async function exportConversations(options) { }); } - window?.log?.info('Done exporting conversations!'); + window.log.info('Done exporting conversations!'); } function getDirectory(options = {}) { @@ -925,7 +925,7 @@ async function saveAllMessages(rawMessages) { await window.Signal.Data.saveMessages(messages); - window?.log?.info( + window.log.info( 'Saved', messages.length, 'messages for conversation', @@ -933,7 +933,7 @@ async function saveAllMessages(rawMessages) { `[REDACTED]${conversationId.slice(-3)}` ); } catch (error) { - window?.log?.error('saveAllMessages error', error && error.message ? error.message : error); + window.log.error('saveAllMessages error', error && error.message ? error.message : error); } } @@ -956,7 +956,7 @@ async function importConversation(dir, options) { try { contents = await readFileAsText(dir, 'messages.json'); } catch (error) { - window?.log?.error(`Warning: could not access messages.json in directory: ${dir}`); + window.log.error(`Warning: could not access messages.json in directory: ${dir}`); } let promiseChain = Promise.resolve(); @@ -1007,7 +1007,7 @@ async function importConversation(dir, options) { await saveAllMessages(messages); await promiseChain; - window?.log?.info( + window.log.info( 'Finished importing conversation', conversationId, 'Total:', @@ -1160,10 +1160,10 @@ async function exportToDirectory(directory, options) { await compressArchive(archivePath, stagingDir); await encryptFile(archivePath, path.join(directory, ARCHIVE_NAME), options); - window?.log?.info('done backing up!'); + window.log.info('done backing up!'); return directory; } catch (error) { - window?.log?.error('The backup went wrong!', error && error.stack ? error.stack : error); + window.log.error('The backup went wrong!', error && error.stack ? error.stack : error); throw error; } finally { if (stagingDir) { @@ -1223,7 +1223,7 @@ async function importFromDirectory(directory, options) { const result = await importNonMessages(stagingDir, options); await importConversations(stagingDir, Object.assign({}, options)); - window?.log?.info('Done importing from backup!'); + window.log.info('Done importing from backup!'); return result; } finally { if (stagingDir) { @@ -1238,10 +1238,10 @@ async function importFromDirectory(directory, options) { const result = await importNonMessages(directory, options); await importConversations(directory, options); - window?.log?.info('Done importing!'); + window.log.info('Done importing!'); return result; } catch (error) { - window?.log?.error('The import went wrong!', error && error.stack ? error.stack : error); + window.log.error('The import went wrong!', error && error.stack ? error.stack : error); throw error; } } diff --git a/js/modules/debuglogs.js b/js/modules/debuglogs.js index 489d2d561..3fd76dd29 100644 --- a/js/modules/debuglogs.js +++ b/js/modules/debuglogs.js @@ -10,7 +10,7 @@ const USER_AGENT = `Session ${VERSION}`; // upload :: String -> Promise URL exports.upload = async content => { - window?.log?.warn('insecureNodeFetch => upload debugLogs'); + window.log.warn('insecureNodeFetch => upload debugLogs'); const signedForm = await insecureNodeFetch(BASE_URL, { headers: { 'user-agent': USER_AGENT, diff --git a/js/modules/loki_app_dot_net_api.js b/js/modules/loki_app_dot_net_api.js index e8e740de8..d058f46aa 100644 --- a/js/modules/loki_app_dot_net_api.js +++ b/js/modules/loki_app_dot_net_api.js @@ -436,7 +436,7 @@ class LokiAppDotNetServerAPI { const anyFailures = results.some(test => !test); if (anyFailures) { - window?.log?.info('failed to add moderator:', results); + window.log.info('failed to add moderator:', results); } return !anyFailures; } @@ -460,7 +460,7 @@ class LokiAppDotNetServerAPI { ); const anyFailures = results.some(test => !test); if (anyFailures) { - window?.log?.info('failed to remove moderator:', results); + window.log.info('failed to remove moderator:', results); } return !anyFailures; } @@ -716,7 +716,7 @@ class LokiPublicChannelAPI { const item = await window.Signal.Data.getItemById('identityKey'); const keyPair = (item && item.value) || undefined; if (!keyPair) { - window?.log?.error('Could not get our Keypair from getItemById'); + window.log.error('Could not get our Keypair from getItemById'); } this.myPrivateKey = keyPair.privKey; } @@ -1409,7 +1409,7 @@ class LokiPublicChannelAPI { // - update their conversation with a potentially new avatar return messageData; } catch (e) { - window?.log?.error('pollOnceForMessages: caught error:', e); + window.log.error('pollOnceForMessages: caught error:', e); return false; } }) diff --git a/js/modules/util_worker_interface.js b/js/modules/util_worker_interface.js index 3b3de1f89..c2c8a3495 100644 --- a/js/modules/util_worker_interface.js +++ b/js/modules/util_worker_interface.js @@ -49,7 +49,7 @@ class WorkerInterface { const id = this._jobCounter; if (this._DEBUG) { - window?.log?.info(`Worker job ${id} (${fnName}) started`); + window.log.info(`Worker job ${id} (${fnName}) started`); } this._jobs[id] = { fnName, @@ -70,14 +70,14 @@ class WorkerInterface { this._removeJob(id); const end = Date.now(); if (this._DEBUG) { - window?.log?.info(`Worker job ${id} (${fnName}) succeeded in ${end - start}ms`); + window.log.info(`Worker job ${id} (${fnName}) succeeded in ${end - start}ms`); } return resolve(value); }, reject: error => { this._removeJob(id); const end = Date.now(); - window?.log?.info(`Worker job ${id} (${fnName}) failed in ${end - start}ms`); + window.log.info(`Worker job ${id} (${fnName}) failed in ${end - start}ms`); return reject(error); }, }; diff --git a/js/notifications.js b/js/notifications.js index ddc5690f3..f96f5db12 100644 --- a/js/notifications.js +++ b/js/notifications.js @@ -72,7 +72,7 @@ userSetting, }); - // window?.log?.info( + // window.log.info( // 'Update notifications:', // Object.assign({}, status, { // isNotificationGroupingSupported, @@ -138,7 +138,7 @@ iconUrl = last.iconUrl; break; default: - window?.log?.error(`Error: Unknown user notification setting: '${userSetting}'`); + window.log.error(`Error: Unknown user notification setting: '${userSetting}'`); break; } @@ -166,11 +166,11 @@ return storage.get('notification-setting') || SettingNames.MESSAGE; }, onRemove() { - // window?.log?.info('Remove notification'); + // window.log.info('Remove notification'); this.update(); }, clear() { - // window?.log?.info('Remove all notifications'); + // window.log.info('Remove all notifications'); this.reset([]); this.update(); }, diff --git a/js/read_receipts.js b/js/read_receipts.js index d581f41ba..5f254c266 100644 --- a/js/read_receipts.js +++ b/js/read_receipts.js @@ -30,7 +30,7 @@ _.contains(ids, receipt.get('reader')) ); if (receipts.length) { - window?.log?.info('Found early read receipts for message'); + window.log.info('Found early read receipts for message'); this.remove(receipts); } return receipts; @@ -66,7 +66,7 @@ const message = await this.getTargetMessage(receipt.get('reader'), messages); if (!message) { - window?.log?.info( + window.log.info( 'No message for read receipt', receipt.get('reader'), receipt.get('timestamp') @@ -99,7 +99,7 @@ this.remove(receipt); } catch (error) { - window?.log?.error( + window.log.error( 'ReadReceipts.onReceipt error:', error && error.stack ? error.stack : error ); diff --git a/js/read_syncs.js b/js/read_syncs.js index 841452b81..70aebf1c4 100644 --- a/js/read_syncs.js +++ b/js/read_syncs.js @@ -18,7 +18,7 @@ timestamp: message.get('sent_at'), }); if (receipt) { - window?.log?.info('Found early read sync for message'); + window.log.info('Found early read sync for message'); this.remove(receipt); return receipt; } @@ -41,7 +41,7 @@ const wasMessageFound = Boolean(found); const wasNotificationFound = Boolean(notificationForMessage); const wasNotificationRemoved = Boolean(removedNotification); - window?.log?.info('Receive read sync:', { + window.log.info('Receive read sync:', { receiptSender, receiptTimestamp, wasMessageFound, @@ -84,10 +84,7 @@ this.remove(receipt); } catch (error) { - window?.log?.error( - 'ReadSyncs.onReceipt error:', - error && error.stack ? error.stack : error - ); + window.log.error('ReadSyncs.onReceipt error:', error && error.stack ? error.stack : error); } }, }))(); diff --git a/js/reliable_trigger.js b/js/reliable_trigger.js index db6394d04..3942eea9d 100644 --- a/js/reliable_trigger.js +++ b/js/reliable_trigger.js @@ -63,7 +63,7 @@ a2 = args[1], a3 = args[2]; const logError = function(error) { - window?.log?.error( + window.log.error( 'Model caught error triggering', name, 'event:', diff --git a/js/storage.js b/js/storage.js index ccbb01cee..017eee1b3 100644 --- a/js/storage.js +++ b/js/storage.js @@ -17,7 +17,7 @@ throw new Error('Tried to store undefined'); } if (!ready) { - window?.log?.warn('Called storage.put before storage is ready. key:', key); + window.log.warn('Called storage.put before storage is ready. key:', key); } const data = { id: key, value }; @@ -28,7 +28,7 @@ function get(key, defaultValue) { if (!ready) { - window?.log?.warn('Called storage.get before storage is ready. key:', key); + window.log.warn('Called storage.get before storage is ready. key:', key); } const item = items[key]; @@ -41,7 +41,7 @@ async function remove(key) { if (!ready) { - window?.log?.warn('Called storage.get before storage is ready. key:', key); + window.log.warn('Called storage.get before storage is ready. key:', key); } delete items[key]; diff --git a/js/views/debug_log_view.js b/js/views/debug_log_view.js index 4c13b29c8..1ed681538 100644 --- a/js/views/debug_log_view.js +++ b/js/views/debug_log_view.js @@ -27,7 +27,7 @@ this.$('textarea').val(i18n('loading')); // eslint-disable-next-line more/no-then - window?.log?.fetch().then(text => { + window.log.fetch().then(text => { this.$('textarea').val(text); }); }, @@ -56,7 +56,7 @@ this.$('.result').addClass('loading'); try { - const publishedLogURL = await window?.log?.publish(text); + const publishedLogURL = await window.log.publish(text); const view = new Whisper.DebugLogLinkView({ url: publishedLogURL, el: this.$('.result'), @@ -67,7 +67,7 @@ .focus() .select(); } catch (error) { - window?.log?.error('DebugLogView error:', error && error.stack ? error.stack : error); + window.log.error('DebugLogView error:', error && error.stack ? error.stack : error); this.$('.loading').removeClass('loading'); this.$('.result').text(i18n('debugLogError')); } diff --git a/js/views/import_view.js b/js/views/import_view.js index be11525ba..e5f0e5c56 100644 --- a/js/views/import_view.js +++ b/js/views/import_view.js @@ -112,7 +112,7 @@ }, error => { if (error.name !== 'ChooseError') { - window?.log?.error( + window.log.error( 'Error choosing directory:', error && error.stack ? error.stack : error ); @@ -155,7 +155,7 @@ return this.finishLightImport(directory); }) .catch(error => { - window?.log?.error('Error importing:', error && error.stack ? error.stack : error); + window.log.error('Error importing:', error && error.stack ? error.stack : error); this.error = error || new Error('Something went wrong!'); this.state = null; diff --git a/js/views/session_registration_view.js b/js/views/session_registration_view.js index 18c9d17a0..8fa51f5da 100644 --- a/js/views/session_registration_view.js +++ b/js/views/session_registration_view.js @@ -28,7 +28,7 @@ }, log(s) { - window?.log?.info(s); + window.log.info(s); this.$('#status').text(s); }, displayError(error) { diff --git a/js/views/update_group_dialog_view.js b/js/views/update_group_dialog_view.js index b4b0082e8..15e4486da 100644 --- a/js/views/update_group_dialog_view.js +++ b/js/views/update_group_dialog_view.js @@ -146,7 +146,7 @@ const allMembersAfterUpdate = window.Lodash.concat(newMembers, [ourPK]); if (!this.isAdmin) { - window?.log?.warn('Skipping update of members, we are not the admin'); + window.log.warn('Skipping update of members, we are not the admin'); return; } // new members won't include the zombies. We are the admin and we want to remove them not matter what @@ -171,7 +171,7 @@ const xor = _.xor(membersToRemove, notPresentInOld); if (xor.length === 0) { - window?.log?.info('skipping group update: no detected changes in group member list'); + window.log.info('skipping group update: no detected changes in group member list'); return; } diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 698c200d6..4b58ea348 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -15,12 +15,12 @@ function MessageReceiver() { // only do this once to prevent duplicates if (lokiPublicChatAPI) { - window?.log?.info('Binding open group events handler', openGroupBound); + window.log.info('Binding open group events handler', openGroupBound); if (!openGroupBound) { openGroupBound = true; } } else { - window?.log?.warn('Can not handle open group data, API is not available'); + window.log.warn('Can not handle open group data, API is not available'); } } @@ -57,13 +57,13 @@ MessageReceiver.prototype.extend({ this.incoming = [this.pending]; }, stopProcessing() { - window?.log?.info('MessageReceiver: stopProcessing requested'); + window.log.info('MessageReceiver: stopProcessing requested'); this.stoppingProcessing = true; return this.close(); }, shutdown() {}, async close() { - window?.log?.info('MessageReceiver.close()'); + window.log.info('MessageReceiver.close()'); this.calledClose = true; // stop polling all open group rooms diff --git a/libtextsecure/protobufs.js b/libtextsecure/protobufs.js index ad8a1cb6c..8315278d4 100644 --- a/libtextsecure/protobufs.js +++ b/libtextsecure/protobufs.js @@ -13,13 +13,13 @@ const text = `Error loading protos from ${filename} (root: ${window.PROTO_ROOT}) ${ error && error.stack ? error.stack : error }`; - window?.log?.error(text); + window.log.error(text); throw error; } const protos = result.build('signalservice'); if (!protos) { const text = `Error loading protos from ${filename} (root: ${window.PROTO_ROOT})`; - window?.log?.error(text); + window.log.error(text); throw new Error(text); } // eslint-disable-next-line no-restricted-syntax, guard-for-in diff --git a/libtextsecure/task_with_timeout.js b/libtextsecure/task_with_timeout.js index 32456dde8..c44a2a0e7 100644 --- a/libtextsecure/task_with_timeout.js +++ b/libtextsecure/task_with_timeout.js @@ -19,7 +19,7 @@ errorForStack.stack }`; - window?.log?.error(message); + window.log.error(message); return reject(new Error(message)); } @@ -33,7 +33,7 @@ clearTimeout(localTimer); } } catch (error) { - window?.log?.error( + window.log.error( id || '', 'task ran into problem canceling timer. Calling stack:', errorForStack.stack