eslint --fix: let to const

This commit is contained in:
Baptiste Grob
2020-02-04 14:22:02 +01:00
parent c0759980cc
commit 94f5888961
10 changed files with 57 additions and 56 deletions

View File

@@ -304,6 +304,7 @@ class RootCtrl {
&& this.authManager.user.email === email && this.authManager.user.email === email
) { ) {
/** Already signed in, return */ /** Already signed in, return */
// eslint-disable-next-line no-useless-return
return; return;
} else { } else {
/** Sign out */ /** Sign out */

View File

@@ -104,9 +104,9 @@ export class AuthManager extends SFAuthManager {
} }
async verifyAccountPassword(password) { async verifyAccountPassword(password) {
let authParams = await this.getAuthParams(); const authParams = await this.getAuthParams();
let keys = await protocolManager.computeEncryptionKeysForUser(password, authParams); const keys = await protocolManager.computeEncryptionKeysForUser(password, authParams);
let success = keys.mk === (await this.keys()).mk; const success = keys.mk === (await this.keys()).mk;
return success; return success;
} }
@@ -115,8 +115,8 @@ export class AuthManager extends SFAuthManager {
return false; return false;
} }
let latest = protocolManager.version(); const latest = protocolManager.version();
let updateAvailable = await this.protocolVersion() !== latest; const updateAvailable = await this.protocolVersion() !== latest;
if(updateAvailable !== this.securityUpdateAvailable) { if(updateAvailable !== this.securityUpdateAvailable) {
this.securityUpdateAvailable = updateAvailable; this.securityUpdateAvailable = updateAvailable;
this.$rootScope.$broadcast("security-update-status-changed"); this.$rootScope.$broadcast("security-update-status-changed");

View File

@@ -39,7 +39,7 @@ export class ComponentManager extends SNComponentManager {
} }
presentPermissionsDialog(dialog) { presentPermissionsDialog(dialog) {
let scope = this.$rootScope.$new(true); const scope = this.$rootScope.$new(true);
scope.permissionsString = dialog.permissionsString; scope.permissionsString = dialog.permissionsString;
scope.component = dialog.component; scope.component = dialog.component;
scope.callback = dialog.callback; scope.callback = dialog.callback;

View File

@@ -29,10 +29,10 @@ export class KeyboardManager {
} }
modifiersForEvent(event) { modifiersForEvent(event) {
let eventModifiers = KeyboardManager.AllModifiers.filter((modifier) => { const eventModifiers = KeyboardManager.AllModifiers.filter((modifier) => {
// For a modifier like ctrlKey, must check both event.ctrlKey and event.key. // For a modifier like ctrlKey, must check both event.ctrlKey and event.key.
// That's because on keyup, event.ctrlKey would be false, but event.key == Control would be true. // That's because on keyup, event.ctrlKey would be false, but event.key == Control would be true.
let matches = ( const matches = (
((event.ctrlKey || event.key == KeyboardManager.KeyModifierCtrl) && modifier === KeyboardManager.KeyModifierCtrl) || ((event.ctrlKey || event.key == KeyboardManager.KeyModifierCtrl) && modifier === KeyboardManager.KeyModifierCtrl) ||
((event.metaKey || event.key == KeyboardManager.KeyModifierMeta) && modifier === KeyboardManager.KeyModifierMeta) || ((event.metaKey || event.key == KeyboardManager.KeyModifierMeta) && modifier === KeyboardManager.KeyModifierMeta) ||
((event.altKey || event.key == KeyboardManager.KeyModifierAlt) && modifier === KeyboardManager.KeyModifierAlt) || ((event.altKey || event.key == KeyboardManager.KeyModifierAlt) && modifier === KeyboardManager.KeyModifierAlt) ||
@@ -46,13 +46,13 @@ export class KeyboardManager {
} }
eventMatchesKeyAndModifiers(event, key, modifiers = []) { eventMatchesKeyAndModifiers(event, key, modifiers = []) {
let eventModifiers = this.modifiersForEvent(event); const eventModifiers = this.modifiersForEvent(event);
if(eventModifiers.length != modifiers.length) { if(eventModifiers.length != modifiers.length) {
return false; return false;
} }
for(let modifier of modifiers) { for(const modifier of modifiers) {
if(!eventModifiers.includes(modifier)) { if(!eventModifiers.includes(modifier)) {
return false; return false;
} }
@@ -69,7 +69,7 @@ export class KeyboardManager {
} }
notifyObserver(event, keyEventType) { notifyObserver(event, keyEventType) {
for(let observer of this.observers) { for(const observer of this.observers) {
if(observer.element && event.target != observer.element) { if(observer.element && event.target != observer.element) {
continue; continue;
} }
@@ -87,7 +87,7 @@ export class KeyboardManager {
} }
if(this.eventMatchesKeyAndModifiers(event, observer.key, observer.modifiers)) { if(this.eventMatchesKeyAndModifiers(event, observer.key, observer.modifiers)) {
let callback = keyEventType == KeyboardManager.KeyEventDown ? observer.onKeyDown : observer.onKeyUp; const callback = keyEventType == KeyboardManager.KeyEventDown ? observer.onKeyDown : observer.onKeyUp;
if(callback) { if(callback) {
callback(event); callback(event);
} }
@@ -104,7 +104,7 @@ export class KeyboardManager {
} }
addKeyObserver({key, modifiers, onKeyDown, onKeyUp, element, elements, notElement, notElementIds}) { addKeyObserver({key, modifiers, onKeyDown, onKeyUp, element, elements, notElement, notElementIds}) {
let observer = {key, modifiers, onKeyDown, onKeyUp, element, elements, notElement, notElementIds}; const observer = {key, modifiers, onKeyDown, onKeyUp, element, elements, notElement, notElementIds};
this.observers.push(observer); this.observers.push(observer);
return observer; return observer;
} }

View File

@@ -56,7 +56,7 @@ export class MigrationManager extends SFMigrationManager {
} }
} }
for(let editor of editors) { for(const editor of editors) {
this.modelManager.setItemToBeDeleted(editor); this.modelManager.setItemToBeDeleted(editor);
} }
@@ -82,10 +82,10 @@ export class MigrationManager extends SFMigrationManager {
content_type: "SN|Component", content_type: "SN|Component",
handler: async (components) => { handler: async (components) => {
let hasChanges = false; let hasChanges = false;
let notes = this.modelManager.validItemsForContentType("Note"); const notes = this.modelManager.validItemsForContentType("Note");
for(let note of notes) { for(const note of notes) {
for(let component of components) { for(const component of components) {
let clientData = note.getDomainDataItem(component.hosted_url, ComponentManager.ClientDataDomain); const clientData = note.getDomainDataItem(component.hosted_url, ComponentManager.ClientDataDomain);
if(clientData) { if(clientData) {
note.setDomainDataItem(component.uuid, clientData, ComponentManager.ClientDataDomain); note.setDomainDataItem(component.uuid, clientData, ComponentManager.ClientDataDomain);
note.setDomainDataItem(component.hosted_url, null, ComponentManager.ClientDataDomain); note.setDomainDataItem(component.hosted_url, null, ComponentManager.ClientDataDomain);
@@ -116,27 +116,27 @@ export class MigrationManager extends SFMigrationManager {
content_type: "Note", content_type: "Note",
handler: async (notes) => { handler: async (notes) => {
let needsSync = false; const needsSync = false;
let status = this.statusManager.addStatusFromString("Optimizing data..."); let status = this.statusManager.addStatusFromString("Optimizing data...");
let dirtyCount = 0; let dirtyCount = 0;
for(let note of notes) { for(const note of notes) {
if(!note.content) { if(!note.content) {
continue; continue;
} }
let references = note.content.references; const references = note.content.references;
// Remove any tag references, and transfer them to the tag if neccessary. // Remove any tag references, and transfer them to the tag if neccessary.
let newReferences = []; const newReferences = [];
for(let reference of references) { for(const reference of references) {
if(reference.content_type != "Tag") { if(reference.content_type != "Tag") {
newReferences.push(reference); newReferences.push(reference);
continue; continue;
} }
// is Tag content_type, we will not be adding this to newReferences // is Tag content_type, we will not be adding this to newReferences
let tag = this.modelManager.findItem(reference.uuid); const tag = this.modelManager.findItem(reference.uuid);
if(tag && !tag.hasRelationshipWithItem(note)) { if(tag && !tag.hasRelationshipWithItem(note)) {
tag.addItemAsRelationship(note); tag.addItemAsRelationship(note);
this.modelManager.setItemDirty(tag, true); this.modelManager.setItemDirty(tag, true);

View File

@@ -107,13 +107,13 @@ export class ModelManager extends SFModelManager {
} }
notesMatchingSmartTag(tag) { notesMatchingSmartTag(tag) {
let contentTypePredicate = new SFPredicate("content_type", "=", "Note"); const contentTypePredicate = new SFPredicate("content_type", "=", "Note");
let predicates = [contentTypePredicate, tag.content.predicate]; const predicates = [contentTypePredicate, tag.content.predicate];
if(!tag.content.isTrashTag) { if(!tag.content.isTrashTag) {
let notTrashedPredicate = new SFPredicate("content.trashed", "=", false); const notTrashedPredicate = new SFPredicate("content.trashed", "=", false);
predicates.push(notTrashedPredicate); predicates.push(notTrashedPredicate);
} }
let results = this.itemsMatchingPredicates(predicates); const results = this.itemsMatchingPredicates(predicates);
return results; return results;
} }
@@ -126,8 +126,8 @@ export class ModelManager extends SFModelManager {
} }
emptyTrash() { emptyTrash() {
let notes = this.trashedItems(); const notes = this.trashedItems();
for(let note of notes) { for(const note of notes) {
this.setItemToBeDeleted(note); this.setItemToBeDeleted(note);
} }
} }
@@ -141,7 +141,7 @@ export class ModelManager extends SFModelManager {
} }
getSmartTags() { getSmartTags() {
let userTags = this.validItemsForContentType("SN|SmartTag").sort((a, b) => { const userTags = this.validItemsForContentType("SN|SmartTag").sort((a, b) => {
return a.content.title < b.content.title ? -1 : 1; return a.content.title < b.content.title ? -1 : 1;
}); });
return this.systemSmartTags.concat(userTags); return this.systemSmartTags.concat(userTags);

View File

@@ -24,8 +24,8 @@ export class NativeExtManager {
resolveExtensionsManager() { resolveExtensionsManager() {
let contentTypePredicate = new SFPredicate("content_type", "=", "SN|Component"); const contentTypePredicate = new SFPredicate("content_type", "=", "SN|Component");
let packagePredicate = new SFPredicate("package_info.identifier", "=", this.extManagerId); const packagePredicate = new SFPredicate("package_info.identifier", "=", this.extManagerId);
this.singletonManager.registerSingleton([contentTypePredicate, packagePredicate], (resolvedSingleton) => { this.singletonManager.registerSingleton([contentTypePredicate, packagePredicate], (resolvedSingleton) => {
// Resolved Singleton // Resolved Singleton
@@ -45,7 +45,7 @@ export class NativeExtManager {
} }
// Handle addition of SN|ExtensionRepo permission // Handle addition of SN|ExtensionRepo permission
let permission = resolvedSingleton.content.permissions.find((p) => p.name == "stream-items"); const permission = resolvedSingleton.content.permissions.find((p) => p.name == "stream-items");
if(!permission.content_types.includes("SN|ExtensionRepo")) { if(!permission.content_types.includes("SN|ExtensionRepo")) {
permission.content_types.push("SN|ExtensionRepo"); permission.content_types.push("SN|ExtensionRepo");
needsSync = true; needsSync = true;
@@ -57,13 +57,13 @@ export class NativeExtManager {
} }
}, (valueCallback) => { }, (valueCallback) => {
// Safe to create. Create and return object. // Safe to create. Create and return object.
let url = window._extensions_manager_location; const url = window._extensions_manager_location;
if(!url) { if(!url) {
console.error("window._extensions_manager_location must be set."); console.error("window._extensions_manager_location must be set.");
return; return;
} }
let packageInfo = { const packageInfo = {
name: "Extensions", name: "Extensions",
identifier: this.extManagerId identifier: this.extManagerId
}; };
@@ -106,8 +106,8 @@ export class NativeExtManager {
resolveBatchManager() { resolveBatchManager() {
let contentTypePredicate = new SFPredicate("content_type", "=", "SN|Component"); const contentTypePredicate = new SFPredicate("content_type", "=", "SN|Component");
let packagePredicate = new SFPredicate("package_info.identifier", "=", this.batchManagerId); const packagePredicate = new SFPredicate("package_info.identifier", "=", this.batchManagerId);
this.singletonManager.registerSingleton([contentTypePredicate, packagePredicate], (resolvedSingleton) => { this.singletonManager.registerSingleton([contentTypePredicate, packagePredicate], (resolvedSingleton) => {
// Resolved Singleton // Resolved Singleton
@@ -132,13 +132,13 @@ export class NativeExtManager {
} }
}, (valueCallback) => { }, (valueCallback) => {
// Safe to create. Create and return object. // Safe to create. Create and return object.
let url = window._batch_manager_location; const url = window._batch_manager_location;
if(!url) { if(!url) {
console.error("window._batch_manager_location must be set."); console.error("window._batch_manager_location must be set.");
return; return;
} }
let packageInfo = { const packageInfo = {
name: "Batch Manager", name: "Batch Manager",
identifier: this.batchManagerId identifier: this.batchManagerId
}; };

View File

@@ -53,7 +53,7 @@ export class PasscodeManager {
} }
notifiyVisibilityObservers(visible) { notifiyVisibilityObservers(visible) {
for(let callback of this.visibilityObservers) { for(const callback of this.visibilityObservers) {
callback(visible); callback(visible);
} }
} }
@@ -63,7 +63,7 @@ export class PasscodeManager {
} }
async getAutoLockInterval() { async getAutoLockInterval() {
let interval = await this.storageManager.getItem(PasscodeManager.AutoLockIntervalKey, StorageManager.FixedEncrypted); const interval = await this.storageManager.getItem(PasscodeManager.AutoLockIntervalKey, StorageManager.FixedEncrypted);
if(interval) { if(interval) {
return JSON.parse(interval); return JSON.parse(interval);
} else { } else {
@@ -88,7 +88,7 @@ export class PasscodeManager {
async verifyPasscode(passcode) { async verifyPasscode(passcode) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
var params = this.passcodeAuthParams(); var params = this.passcodeAuthParams();
let keys = await protocolManager.computeEncryptionKeysForUser(passcode, params); const keys = await protocolManager.computeEncryptionKeysForUser(passcode, params);
if(keys.pw !== params.hash) { if(keys.pw !== params.hash) {
resolve(false); resolve(false);
} else { } else {
@@ -118,8 +118,8 @@ export class PasscodeManager {
var uuid = protocolManager.crypto.generateUUIDSync(); var uuid = protocolManager.crypto.generateUUIDSync();
protocolManager.generateInitialKeysAndAuthParamsForUser(uuid, passcode).then((results) => { protocolManager.generateInitialKeysAndAuthParamsForUser(uuid, passcode).then((results) => {
let keys = results.keys; const keys = results.keys;
let authParams = results.authParams; const authParams = results.authParams;
authParams.hash = keys.pw; authParams.hash = keys.pw;
this._keys = keys; this._keys = keys;
@@ -264,8 +264,8 @@ export class PasscodeManager {
// Use a timeout if possible, but if the computer is put to sleep, timeouts won't work. // Use a timeout if possible, but if the computer is put to sleep, timeouts won't work.
// Need to set a date as backup. this.lockAfterDate does not need to be persisted, as // Need to set a date as backup. this.lockAfterDate does not need to be persisted, as
// living in memory seems sufficient. If memory is cleared, then the application will lock anyway. // living in memory seems sufficient. If memory is cleared, then the application will lock anyway.
let addToNow = (seconds) => { const addToNow = (seconds) => {
let date = new Date(); const date = new Date();
date.setSeconds(date.getSeconds() + seconds); date.setSeconds(date.getSeconds() + seconds);
return date; return date;
}; };

View File

@@ -21,9 +21,9 @@ export class SessionHistory extends SFSessionHistoryManager {
}); });
var keyRequestHandler = async () => { var keyRequestHandler = async () => {
let offline = authManager.offline(); const offline = authManager.offline();
let auth_params = offline ? passcodeManager.passcodeAuthParams() : await authManager.getAuthParams(); const auth_params = offline ? passcodeManager.passcodeAuthParams() : await authManager.getAuthParams();
let keys = offline ? passcodeManager.keys() : await authManager.keys(); const keys = offline ? passcodeManager.keys() : await authManager.keys();
return { return {
keys: keys, keys: keys,

View File

@@ -123,12 +123,12 @@ export class ThemeManager {
} }
async cacheThemes() { async cacheThemes() {
let mapped = await Promise.all(this.activeThemes.map(async (theme) => { const mapped = await Promise.all(this.activeThemes.map(async (theme) => {
let transformer = new SFItemParams(theme); const transformer = new SFItemParams(theme);
let params = await transformer.paramsForLocalStorage(); const params = await transformer.paramsForLocalStorage();
return params; return params;
})); }));
let data = JSON.stringify(mapped); const data = JSON.stringify(mapped);
return this.storageManager.setItem(ThemeManager.CachedThemesKey, data, StorageManager.Fixed); return this.storageManager.setItem(ThemeManager.CachedThemesKey, data, StorageManager.Fixed);
} }
@@ -137,9 +137,9 @@ export class ThemeManager {
} }
getCachedThemes() { getCachedThemes() {
let cachedThemes = this.storageManager.getItemSync(ThemeManager.CachedThemesKey, StorageManager.Fixed); const cachedThemes = this.storageManager.getItemSync(ThemeManager.CachedThemesKey, StorageManager.Fixed);
if (cachedThemes) { if (cachedThemes) {
let parsed = JSON.parse(cachedThemes); const parsed = JSON.parse(cachedThemes);
return parsed.map((theme) => { return parsed.map((theme) => {
return new SNTheme(theme); return new SNTheme(theme);
}); });