Merge pull request #357 from standardnotes/lint-task

Lint task
This commit is contained in:
Mo Bitar
2020-02-04 09:11:16 -06:00
committed by GitHub
38 changed files with 238 additions and 236 deletions

View File

@@ -15,8 +15,8 @@ export class PureCtrl {
this.$timeout(() => { this.$timeout(() => {
this.state = Object.freeze(Object.assign({}, this.state, state)); this.state = Object.freeze(Object.assign({}, this.state, state));
resolve(); resolve();
}) });
}) });
} }
initProps(props) { initProps(props) {

View File

@@ -85,7 +85,7 @@ class EditorCtrl extends PureCtrl {
editorDebounce: EDITOR_DEBOUNCE, editorDebounce: EDITOR_DEBOUNCE,
isDesktop: isDesktopApplication(), isDesktop: isDesktopApplication(),
spellcheck: true spellcheck: true
} };
this.leftResizeControl = {}; this.leftResizeControl = {};
this.rightResizeControl = {}; this.rightResizeControl = {};
@@ -223,7 +223,7 @@ class EditorCtrl extends PureCtrl {
const editor = this.editorForNote(this.state.note); const editor = this.editorForNote(this.state.note);
this.setState({ this.setState({
selectedEditor: editor selectedEditor: editor
}) });
if (!editor) { if (!editor) {
this.reloadFont(); this.reloadFont();
} }
@@ -247,7 +247,7 @@ class EditorCtrl extends PureCtrl {
/** if we're still dirty, don't change status, a sync is likely upcoming. */ /** if we're still dirty, don't change status, a sync is likely upcoming. */
} else { } else {
const savedItem = data.savedItems.find((item) => { const savedItem = data.savedItems.find((item) => {
return item.uuid === this.state.note.uuid return item.uuid === this.state.note.uuid;
}); });
const isInErrorState = this.state.saveError; const isInErrorState = this.state.saveError;
if (isInErrorState || savedItem) { if (isInErrorState || savedItem) {
@@ -276,9 +276,9 @@ class EditorCtrl extends PureCtrl {
message: "Offline Saving Issue", message: "Offline Saving Issue",
desc: "Changes not saved" desc: "Changes not saved"
}); });
}, 500) }, 500);
} }
}) });
} }
editorForNote(note) { editorForNote(note) {
@@ -574,8 +574,8 @@ class EditorCtrl extends PureCtrl {
this.appState.setSelectedNote(null); this.appState.setSelectedNote(null);
this.setMenuState('showOptionsMenu', false); this.setMenuState('showOptionsMenu', false);
} }
}) });
} };
const requiresPrivilege = await this.privilegesManager.actionRequiresPrivilege( const requiresPrivilege = await this.privilegesManager.actionRequiresPrivilege(
PrivilegesManager.ActionDeleteNote PrivilegesManager.ActionDeleteNote
); );
@@ -631,7 +631,7 @@ class EditorCtrl extends PureCtrl {
this.modelManager.emptyTrash(); this.modelManager.emptyTrash();
this.syncManager.sync(); this.syncManager.sync();
} }
}) });
} }
togglePin() { togglePin() {
@@ -755,7 +755,7 @@ class EditorCtrl extends PureCtrl {
return string.length > 0; return string.length > 0;
}).map((string) => { }).map((string) => {
return string.trim(); return string.trim();
}) });
this.state.note.dummy = false; this.state.note.dummy = false;
this.updateTags(strings); this.updateTags(strings);
} }
@@ -862,16 +862,16 @@ class EditorCtrl extends PureCtrl {
/** Allows textarea to reload */ /** Allows textarea to reload */
await this.setState({ await this.setState({
noteReady: false noteReady: false
}) });
this.setState({ this.setState({
noteReady: true noteReady: true
}) });
this.reloadFont(); this.reloadFont();
} else if (key === PREF_EDITOR_RESIZERS_ENABLED && this[key] === true) { } else if (key === PREF_EDITOR_RESIZERS_ENABLED && this[key] === true) {
this.$timeout(() => { this.$timeout(() => {
this.leftResizeControl.flash(); this.leftResizeControl.flash();
this.rightResizeControl.flash(); this.rightResizeControl.flash();
}) });
} }
} }
@@ -961,7 +961,7 @@ class EditorCtrl extends PureCtrl {
'style', 'style',
`width: ${widthString}; height: ${heightString};` `width: ${widthString}; height: ${heightString};`
); );
} };
if (data.type === 'container') { if (data.type === 'container') {
if (component.area === 'note-tags') { if (component.area === 'note-tags') {
const container = document.getElementById( const container = document.getElementById(
@@ -983,7 +983,7 @@ class EditorCtrl extends PureCtrl {
} }
else if (action === 'save-items') { else if (action === 'save-items') {
const includesNote = data.items.map((item) => { const includesNote = data.items.map((item) => {
return item.uuid return item.uuid;
}).includes(this.state.note.uuid); }).includes(this.state.note.uuid);
if (includesNote) { if (includesNote) {
this.showSavingStatus(); this.showSavingStatus();
@@ -1001,7 +1001,7 @@ class EditorCtrl extends PureCtrl {
this.setState({ this.setState({
state: components state: components
}) });
} }
reloadComponentContext() { reloadComponentContext() {
@@ -1071,14 +1071,14 @@ class EditorCtrl extends PureCtrl {
onKeyDown: () => { onKeyDown: () => {
this.setState({ this.setState({
altKeyDown: true altKeyDown: true
}) });
}, },
onKeyUp: () => { onKeyUp: () => {
this.setState({ this.setState({
altKeyDown: false altKeyDown: false
}); });
} }
}) });
this.trashKeyObserver = this.keyboardManager.addKeyObserver({ this.trashKeyObserver = this.keyboardManager.addKeyObserver({
key: KeyboardManager.KeyBackspace, key: KeyboardManager.KeyBackspace,
@@ -1090,7 +1090,7 @@ class EditorCtrl extends PureCtrl {
onKeyDown: () => { onKeyDown: () => {
this.deleteNote(); this.deleteNote();
}, },
}) });
this.deleteKeyObserver = this.keyboardManager.addKeyObserver({ this.deleteKeyObserver = this.keyboardManager.addKeyObserver({
key: KeyboardManager.KeyBackspace, key: KeyboardManager.KeyBackspace,
@@ -1103,7 +1103,7 @@ class EditorCtrl extends PureCtrl {
event.preventDefault(); event.preventDefault();
this.deleteNote(true); this.deleteNote(true);
}, },
}) });
} }
onSystemEditorLoad() { onSystemEditorLoad() {

View File

@@ -127,7 +127,7 @@ class FooterCtrl {
this.findErrors(); this.findErrors();
this.updateOfflineStatus(); this.updateOfflineStatus();
} }
}) });
}); });
} }
@@ -137,7 +137,7 @@ class FooterCtrl {
'SN|Component', 'SN|Component',
(allItems, validItems, deletedItems, source) => { (allItems, validItems, deletedItems, source) => {
this.rooms = this.modelManager.components.filter((candidate) => { this.rooms = this.modelManager.components.filter((candidate) => {
return candidate.area === 'rooms' && !candidate.deleted return candidate.area === 'rooms' && !candidate.deleted;
}); });
if(this.queueExtReload) { if(this.queueExtReload) {
this.queueExtReload = false; this.queueExtReload = false;
@@ -259,7 +259,7 @@ class FooterCtrl {
}).then((response) => { }).then((response) => {
this.$timeout(() => { this.$timeout(() => {
this.isRefreshing = false; this.isRefreshing = false;
}, 200) }, 200);
if(response && response.error) { if(response && response.error) {
this.alertManager.alert({ this.alertManager.alert({
text: STRING_GENERIC_SYNC_ERROR text: STRING_GENERIC_SYNC_ERROR
@@ -282,7 +282,7 @@ class FooterCtrl {
this.newUpdateAvailable = false; this.newUpdateAvailable = false;
this.alertManager.alert({ this.alertManager.alert({
text: STRING_NEW_UPDATE_READY text: STRING_NEW_UPDATE_READY
}) });
} }
reloadDockShortcuts() { reloadDockShortcuts() {
@@ -297,7 +297,7 @@ class FooterCtrl {
name: name, name: name,
component: theme, component: theme,
icon: icon icon: icon
}) });
} }
this.dockShortcuts = shortcuts.sort((a, b) => { this.dockShortcuts = shortcuts.sort((a, b) => {
@@ -341,8 +341,8 @@ class FooterCtrl {
const run = () => { const run = () => {
this.$timeout(() => { this.$timeout(() => {
room.showRoom = !room.showRoom; room.showRoom = !room.showRoom;
}) });
} };
if(!room.showRoom) { if(!room.showRoom) {
const requiresPrivilege = await this.privilegesManager.actionRequiresPrivilege( const requiresPrivilege = await this.privilegesManager.actionRequiresPrivilege(

View File

@@ -44,7 +44,7 @@ class LockScreenCtrl {
input.focus(); input.focus();
} }
} }
}) });
} }
submitPasscodeForm($event) { submitPasscodeForm($event) {
@@ -83,9 +83,9 @@ class LockScreenCtrl {
onConfirm: () => { onConfirm: () => {
this.authManager.signout(true).then(() => { this.authManager.signout(true).then(() => {
window.location.reload(); window.location.reload();
}) });
} }
}) });
} }
} }

View File

@@ -23,7 +23,7 @@ export function filterAndSortNotes({
notes: filtered, notes: filtered,
sortBy, sortBy,
reverse reverse
}) });
return sorted; return sorted;
} }
@@ -102,7 +102,7 @@ function stringIsUuid(text) {
const matches = text.match( const matches = text.match(
/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/ /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/
); );
return matches ? true : false; return !!matches;
} }
export function sortNotes({ export function sortNotes({
@@ -143,10 +143,10 @@ export function sortNotes({
if (aValue > bValue) { return -1 * vector; } if (aValue > bValue) { return -1 * vector; }
else if (aValue < bValue) { return 1 * vector; } else if (aValue < bValue) { return 1 * vector; }
return 0; return 0;
} };
const result = notes.sort(function (a, b) { const result = notes.sort(function (a, b) {
return sortValueFn(a, b); return sortValueFn(a, b);
}) });
return result; return result;
} }

View File

@@ -80,7 +80,7 @@ class NotesCtrl extends PureCtrl {
panelTitle: null, panelTitle: null,
mutable: { showMenu: false }, mutable: { showMenu: false },
noteFilter: { text: '' }, noteFilter: { text: '' },
} };
this.panelController = {}; this.panelController = {};
window.onresize = (event) => { window.onresize = (event) => {
@@ -124,7 +124,7 @@ class NotesCtrl extends PureCtrl {
this.modelManager.removeItemLocally(this.state.selectedNote); this.modelManager.removeItemLocally(this.state.selectedNote);
this.selectNote(null).then(() => { this.selectNote(null).then(() => {
this.reloadNotes(); this.reloadNotes();
}) });
/** /**
* We want to see if the user will download any items from the server. * We want to see if the user will download any items from the server.
* If the next sync completes and our notes are still 0, * If the next sync completes and our notes are still 0,
@@ -133,7 +133,7 @@ class NotesCtrl extends PureCtrl {
this.createDummyOnSynCompletionIfNoNotes = true; this.createDummyOnSynCompletionIfNoNotes = true;
} }
} }
}) });
} }
addSyncEventHandler() { addSyncEventHandler() {
@@ -270,7 +270,7 @@ class NotesCtrl extends PureCtrl {
...this.state.mutable, ...this.state.mutable,
showMenu: false showMenu: false
} }
}) });
} }
async handleNoteSelection(note) { async handleNoteSelection(note) {
@@ -284,7 +284,7 @@ class NotesCtrl extends PureCtrl {
} }
await this.setState({ await this.setState({
selectedNote: note selectedNote: note
}) });
if (!note) { if (!note) {
return; return;
} }
@@ -351,7 +351,7 @@ class NotesCtrl extends PureCtrl {
this.appState.panelDidResize({ this.appState.panelDidResize({
name: PANEL_NAME_NOTES, name: PANEL_NAME_NOTES,
collapsed: this.panelController.isCollapsed() collapsed: this.panelController.isCollapsed()
}) });
} }
} }
} }
@@ -391,14 +391,14 @@ class NotesCtrl extends PureCtrl {
reloadPanelTitle() { reloadPanelTitle() {
let title; let title;
if (this.isFiltering()) { if (this.isFiltering()) {
const resultCount = this.state.notes.length const resultCount = this.state.notes.length;
title = `${resultCount} search results`; title = `${resultCount} search results`;
} else if (this.state.tag) { } else if (this.state.tag) {
title = `${this.state.tag.title}`; title = `${this.state.tag.title}`;
} }
this.setState({ this.setState({
panelTitle: title panelTitle: title
}) });
} }
optionsSubtitle() { optionsSubtitle() {
@@ -411,13 +411,13 @@ class NotesCtrl extends PureCtrl {
base += " Title"; base += " Title";
} }
if (this.state.showArchived) { if (this.state.showArchived) {
base += " | + Archived" base += " | + Archived";
} }
if (this.state.hidePinned) { if (this.state.hidePinned) {
base += " | Pinned" base += " | Pinned";
} }
if (this.state.sortReverse) { if (this.state.sortReverse) {
base += " | Reversed" base += " | Reversed";
} }
return base; return base;
} }
@@ -428,49 +428,49 @@ class NotesCtrl extends PureCtrl {
flags.push({ flags.push({
text: "Pinned", text: "Pinned",
class: 'info' class: 'info'
}) });
} }
if (note.archived) { if (note.archived) {
flags.push({ flags.push({
text: "Archived", text: "Archived",
class: 'warning' class: 'warning'
}) });
} }
if (note.content.protected) { if (note.content.protected) {
flags.push({ flags.push({
text: "Protected", text: "Protected",
class: 'success' class: 'success'
}) });
} }
if (note.locked) { if (note.locked) {
flags.push({ flags.push({
text: "Locked", text: "Locked",
class: 'neutral' class: 'neutral'
}) });
} }
if (note.content.trashed) { if (note.content.trashed) {
flags.push({ flags.push({
text: "Deleted", text: "Deleted",
class: 'danger' class: 'danger'
}) });
} }
if (note.content.conflict_of) { if (note.content.conflict_of) {
flags.push({ flags.push({
text: "Conflicted Copy", text: "Conflicted Copy",
class: 'danger' class: 'danger'
}) });
} }
if (note.errorDecrypting) { if (note.errorDecrypting) {
flags.push({ flags.push({
text: "Missing Keys", text: "Missing Keys",
class: 'danger' class: 'danger'
}) });
} }
if (note.deleted) { if (note.deleted) {
flags.push({ flags.push({
text: "Deletion Pending Sync", text: "Deletion Pending Sync",
class: 'danger' class: 'danger'
}) });
} }
note.flags = flags; note.flags = flags;
return flags; return flags;
@@ -566,7 +566,7 @@ class NotesCtrl extends PureCtrl {
...this.state.noteFilter, ...this.state.noteFilter,
text: text text: text
} }
}) });
} }
async clearFilterText() { async clearFilterText() {
@@ -671,7 +671,7 @@ class NotesCtrl extends PureCtrl {
event.preventDefault(); event.preventDefault();
this.createNewNote(); this.createNewNote();
} }
}) });
this.nextNoteKeyObserver = this.keyboardManager.addKeyObserver({ this.nextNoteKeyObserver = this.keyboardManager.addKeyObserver({
key: KeyboardManager.KeyDown, key: KeyboardManager.KeyDown,
@@ -682,11 +682,11 @@ class NotesCtrl extends PureCtrl {
onKeyDown: (event) => { onKeyDown: (event) => {
const searchBar = this.getSearchBar(); const searchBar = this.getSearchBar();
if (searchBar === document.activeElement) { if (searchBar === document.activeElement) {
searchBar.blur() searchBar.blur();
} }
this.selectNextNote(); this.selectNextNote();
} }
}) });
this.nextNoteKeyObserver = this.keyboardManager.addKeyObserver({ this.nextNoteKeyObserver = this.keyboardManager.addKeyObserver({
key: KeyboardManager.KeyUp, key: KeyboardManager.KeyUp,
@@ -704,9 +704,9 @@ class NotesCtrl extends PureCtrl {
], ],
onKeyDown: (event) => { onKeyDown: (event) => {
const searchBar = this.getSearchBar(); const searchBar = this.getSearchBar();
if (searchBar) { searchBar.focus() }; if (searchBar) { searchBar.focus(); };
} }
}) });
} }
} }

View File

@@ -118,7 +118,7 @@ class RootCtrl {
if(this.tagsCollapsed) { appClass += " collapsed-tags"; } if(this.tagsCollapsed) { appClass += " collapsed-tags"; }
this.$scope.appClass = appClass; this.$scope.appClass = appClass;
} }
}) });
} }
loadAfterUnlock() { loadAfterUnlock() {
@@ -143,13 +143,13 @@ class RootCtrl {
this.syncManager.clearSyncToken(); this.syncManager.clearSyncToken();
this.syncManager.sync(); this.syncManager.sync();
} }
}) });
} }
addSyncStatusObserver() { addSyncStatusObserver() {
this.syncStatusObserver = this.syncManager.registerSyncStatusObserver((status) => { this.syncStatusObserver = this.syncManager.registerSyncStatusObserver((status) => {
if(status.retrievedCount > 20) { if(status.retrievedCount > 20) {
const text = `Downloading ${status.retrievedCount} items. Keep app open.` const text = `Downloading ${status.retrievedCount} items. Keep app open.`;
this.syncStatus = this.statusManager.replaceStatusWithString( this.syncStatus = this.statusManager.replaceStatusWithString(
this.syncStatus, this.syncStatus,
text text
@@ -230,7 +230,7 @@ class RootCtrl {
encryptionEnabled ? "Decrypting items..." : "Loading items..." encryptionEnabled ? "Decrypting items..." : "Loading items..."
); );
const incrementalCallback = (current, total) => { const incrementalCallback = (current, total) => {
const notesString = `${current}/${total} items...` const notesString = `${current}/${total} items...`;
const status = encryptionEnabled const status = encryptionEnabled
? `Decrypting ${notesString}` ? `Decrypting ${notesString}`
: `Loading ${notesString}`; : `Loading ${notesString}`;
@@ -238,7 +238,7 @@ class RootCtrl {
this.syncStatus, this.syncStatus,
status status
); );
} };
this.syncManager.loadLocalItems({incrementalCallback}).then(() => { this.syncManager.loadLocalItems({incrementalCallback}).then(() => {
this.$timeout(() => { this.$timeout(() => {
this.$rootScope.$broadcast("initial-data-loaded"); this.$rootScope.$broadcast("initial-data-loaded");
@@ -250,7 +250,7 @@ class RootCtrl {
performIntegrityCheck: true performIntegrityCheck: true
}).then(() => { }).then(() => {
this.syncStatus = this.statusManager.removeStatus(this.syncStatus); this.syncStatus = this.statusManager.removeStatus(this.syncStatus);
}) });
setInterval(() => { setInterval(() => {
this.syncManager.sync(); this.syncManager.sync();
}, AUTO_SYNC_INTERVAL); }, AUTO_SYNC_INTERVAL);
@@ -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 */
@@ -321,9 +322,9 @@ class RootCtrl {
{} {}
).then((response) => { ).then((response) => {
window.location.reload(); window.location.reload();
}) });
} }
} };
if(urlParam('server')) { if(urlParam('server')) {
autoSignInFromParams(); autoSignInFromParams();

View File

@@ -294,7 +294,7 @@ class AccountMenuCtrl extends PureCtrl {
*/ */
async clearDatabaseAndRewriteAllItems({ alternateUuids } = {}) { async clearDatabaseAndRewriteAllItems({ alternateUuids } = {}) {
await this.storageManager.clearAllModels(); await this.storageManager.clearAllModels();
await this.syncManager.markAllItemsDirtyAndSaveOffline(alternateUuids) await this.syncManager.markAllItemsDirtyAndSaveOffline(alternateUuids);
} }
destroyLocalData() { destroyLocalData() {

View File

@@ -16,7 +16,7 @@ class ActionsMenuCtrl extends PureCtrl {
$onInit() { $onInit() {
this.initProps({ this.initProps({
item: this.item item: this.item
}) });
this.loadExtensions(); this.loadExtensions();
}; };
@@ -57,7 +57,7 @@ class ActionsMenuCtrl extends PureCtrl {
await this.actionsManager.loadExtensionInContextOfItem(extension, this.props.item); await this.actionsManager.loadExtensionInContextOfItem(extension, this.props.item);
this.setState({ this.setState({
extensions: this.state.extensions extensions: this.state.extensions
}) });
} }
handleActionResult(action, result) { handleActionResult(action, result) {
@@ -84,8 +84,8 @@ class ActionsMenuCtrl extends PureCtrl {
label: subaction.label, label: subaction.label,
subtitle: subaction.desc, subtitle: subaction.desc,
spinnerClass: subaction.running ? 'info' : null spinnerClass: subaction.running ? 'info' : null
} };
}) });
} }
} }

View File

@@ -11,7 +11,7 @@ export class ComponentModalCtrl {
this.$element.remove(); this.$element.remove();
this.$scope.$destroy(); this.$scope.$destroy();
if(this.onDismiss && this.onDismiss()) { if(this.onDismiss && this.onDismiss()) {
this.onDismiss()(this.component) this.onDismiss()(this.component);
} }
callback && callback(); callback && callback();
} }

View File

@@ -30,7 +30,7 @@ class ComponentViewCtrl {
}); });
$scope.$on('ext-reload-complete', () => { $scope.$on('ext-reload-complete', () => {
this.reloadStatus(false); this.reloadStatus(false);
}) });
$scope.$on('$destroy', () => { $scope.$on('$destroy', () => {
this.destroy(); this.destroy();
}); });
@@ -47,7 +47,7 @@ class ComponentViewCtrl {
if(component === this.component && component.active) { if(component === this.component && component.active) {
this.reloadComponent(); this.reloadComponent();
} }
}) });
} }
registerComponentHandlers() { registerComponentHandlers() {
@@ -70,7 +70,7 @@ class ComponentViewCtrl {
} }
this.$timeout(() => { this.$timeout(() => {
this.handleActivation(); this.handleActivation();
}) });
}, },
actionHandler: (component, action, data) => { actionHandler: (component, action, data) => {
if(action === 'set-size') { if(action === 'set-size') {
@@ -116,9 +116,9 @@ class ComponentViewCtrl {
this.loading = false; this.loading = false;
} }
if(offlineRestricted) { if(offlineRestricted) {
this.error = 'offline-restricted' this.error = 'offline-restricted';
} else if(hasUrlError) { } else if(hasUrlError) {
this.error = 'url-missing' this.error = 'url-missing';
} else { } else {
this.error = null; this.error = null;
} }
@@ -133,7 +133,7 @@ class ComponentViewCtrl {
this.reloadThemeStatus(); this.reloadThemeStatus();
this.$timeout(() => { this.$timeout(() => {
this.reloading = false; this.reloading = false;
}, 500) }, 500);
} }
handleActivation() { handleActivation() {
@@ -193,9 +193,9 @@ class ComponentViewCtrl {
const avoidFlickerTimeout = 7; const avoidFlickerTimeout = 7;
this.$timeout(() => { this.$timeout(() => {
this.loading = false; this.loading = false;
this.issueLoading = desktopError ? true : false; this.issueLoading = !!desktopError;
this.onLoad && this.onLoad(this.component); this.onLoad && this.onLoad(this.component);
}, avoidFlickerTimeout) }, avoidFlickerTimeout);
} }
componentValueDidSet(component, prevComponent) { componentValueDidSet(component, prevComponent) {

View File

@@ -38,7 +38,7 @@ class ConflictResolutionCtrl {
this.modelManager.setItemToBeDeleted(this.item2); this.modelManager.setItemToBeDeleted(this.item2);
this.syncManager.sync().then(() => { this.syncManager.sync().then(() => {
this.applyCallback(); this.applyCallback();
}) });
this.dismiss(); this.dismiss();
} }
}); });
@@ -52,7 +52,7 @@ class ConflictResolutionCtrl {
this.modelManager.setItemToBeDeleted(this.item1); this.modelManager.setItemToBeDeleted(this.item1);
this.syncManager.sync().then(() => { this.syncManager.sync().then(() => {
this.applyCallback(); this.applyCallback();
}) });
this.dismiss(); this.dismiss();
} }
}); });

View File

@@ -17,7 +17,7 @@ class EditorMenuCtrl extends PureCtrl {
this.syncManager = syncManager; this.syncManager = syncManager;
this.state = { this.state = {
isDesktop: isDesktopApplication() isDesktop: isDesktopApplication()
} };
} }
$onInit() { $onInit() {
@@ -29,7 +29,7 @@ class EditorMenuCtrl extends PureCtrl {
this.setState({ this.setState({
editors: editors, editors: editors,
defaultEditor: defaultEditor defaultEditor: defaultEditor
}) });
}; };
selectComponent(component) { selectComponent(component) {
@@ -42,7 +42,7 @@ class EditorMenuCtrl extends PureCtrl {
} }
this.$timeout(() => { this.$timeout(() => {
this.callback()(component); this.callback()(component);
}) });
} }
toggleDefaultForEditor(editor) { toggleDefaultForEditor(editor) {
@@ -70,7 +70,7 @@ class EditorMenuCtrl extends PureCtrl {
this.syncManager.sync(); this.syncManager.sync();
this.setState({ this.setState({
defaultEditor: component defaultEditor: component
}) });
} }
removeEditorDefault(component) { removeEditorDefault(component) {
@@ -79,7 +79,7 @@ class EditorMenuCtrl extends PureCtrl {
this.syncManager.sync(); this.syncManager.sync();
this.setState({ this.setState({
defaultEditor: null defaultEditor: null
}) });
} }
shouldDisplayRunningLocallyLabel(component) { shouldDisplayRunningLocallyLabel(component) {

View File

@@ -10,7 +10,7 @@ const Steps = {
PasswordStep: 3, PasswordStep: 3,
SyncStep: 4, SyncStep: 4,
FinishStep: 5 FinishStep: 5
} };
class PasswordWizardCtrl { class PasswordWizardCtrl {
/* @ngInject */ /* @ngInject */
@@ -95,12 +95,12 @@ class PasswordWizardCtrl {
this.step++; this.step++;
this.initializeStep(this.step); this.initializeStep(this.step);
this.isContinuing = false; this.isContinuing = false;
} };
const preprocessor = this.preprocessorForStep(this.step); const preprocessor = this.preprocessorForStep(this.step);
if (preprocessor) { if (preprocessor) {
await preprocessor().then(next).catch(() => { await preprocessor().then(next).catch(() => {
this.isContinuing = false; this.isContinuing = false;
}) });
} else { } else {
next(); next();
} }
@@ -115,7 +115,7 @@ class PasswordWizardCtrl {
this.showSpinner = false; this.showSpinner = false;
this.continueTitle = DEFAULT_CONTINUE_TITLE; this.continueTitle = DEFAULT_CONTINUE_TITLE;
return success; return success;
} };
} }
} }
@@ -212,7 +212,7 @@ class PasswordWizardCtrl {
if (!response || response.error) { if (!response || response.error) {
this.alertManager.alert({ this.alertManager.alert({
text: STRING_FAILED_PASSWORD_CHANGE text: STRING_FAILED_PASSWORD_CHANGE
}) });
return false; return false;
} else { } else {
return true; return true;

View File

@@ -18,8 +18,8 @@ class PrivilegesAuthModalCtrl {
this.privilegesManager.getSelectedSessionLength().then((length) => { this.privilegesManager.getSelectedSessionLength().then((length) => {
this.$timeout(() => { this.$timeout(() => {
this.selectedSessionLength = length; this.selectedSessionLength = length;
}) });
}) });
this.privilegesManager.netCredentialsForAction(this.action).then((credentials) => { this.privilegesManager.netCredentialsForAction(this.action).then((credentials) => {
this.$timeout(() => { this.$timeout(() => {
this.requiredCredentials = credentials.sort(); this.requiredCredentials = credentials.sort();
@@ -77,7 +77,7 @@ class PrivilegesAuthModalCtrl {
} else { } else {
this.failedCredentials = result.failedCredentials; this.failedCredentials = result.failedCredentials;
} }
}) });
} }
dismiss() { dismiss() {

View File

@@ -59,7 +59,7 @@ class PrivilegesManagementModalCtrl {
const privs = await this.privilegesManager.getPrivileges(); const privs = await this.privilegesManager.getPrivileges();
this.$timeout(() => { this.$timeout(() => {
this.privileges = privs; this.privileges = privs;
}) });
} }
checkboxValueChanged(action, credential) { checkboxValueChanged(action, credential) {

View File

@@ -99,14 +99,14 @@ class RevisionPreviewModalCtrl {
this.modelManager.setItemDirty(item); this.modelManager.setItemDirty(item);
this.syncManager.sync(); this.syncManager.sync();
this.dismiss(); this.dismiss();
} };
if (!asCopy) { if (!asCopy) {
this.alertManager.confirm({ this.alertManager.confirm({
text: "Are you sure you want to replace the current note's contents with what you see in this preview?", text: "Are you sure you want to replace the current note's contents with what you see in this preview?",
destructive: true, destructive: true,
onConfirm: run onConfirm: run
}) });
} else { } else {
run(); run();
} }

View File

@@ -24,7 +24,7 @@ class SessionHistoryMenuCtrl {
const history = this.sessionHistory.historyForItem(this.item); const history = this.sessionHistory.historyForItem(this.item);
this.entries = history.entries.slice(0).sort((a, b) => { this.entries = history.entries.slice(0).sort((a, b) => {
return a.item.updated_at < b.item.updated_at ? 1 : -1; return a.item.updated_at < b.item.updated_at ? 1 : -1;
}) });
this.history = history; this.history = history;
} }
@@ -54,10 +54,10 @@ class SessionHistoryMenuCtrl {
this.sessionHistory.clearHistoryForItem(this.item).then(() => { this.sessionHistory.clearHistoryForItem(this.item).then(() => {
this.$timeout(() => { this.$timeout(() => {
this.reloadHistory(); this.reloadHistory();
}) });
}); });
} }
}) });
} }
clearAllHistory() { clearAllHistory() {
@@ -68,10 +68,10 @@ class SessionHistoryMenuCtrl {
this.sessionHistory.clearAllHistory().then(() => { this.sessionHistory.clearAllHistory().then(() => {
this.$timeout(() => { this.$timeout(() => {
this.reloadHistory(); this.reloadHistory();
}) });
}); });
} }
}) });
} }
toggleDiskSaving() { toggleDiskSaving() {
@@ -79,9 +79,9 @@ class SessionHistoryMenuCtrl {
this.sessionHistory.toggleDiskSaving().then(() => { this.sessionHistory.toggleDiskSaving().then(() => {
this.$timeout(() => { this.$timeout(() => {
this.diskEnabled = this.sessionHistory.diskEnabled; this.diskEnabled = this.sessionHistory.diskEnabled;
}) });
}); });
} };
if (!this.sessionHistory.diskEnabled) { if (!this.sessionHistory.diskEnabled) {
this.alertManager.confirm({ this.alertManager.confirm({
text: `Are you sure you want to save history to disk? This will decrease general text: `Are you sure you want to save history to disk? This will decrease general
@@ -89,7 +89,7 @@ class SessionHistoryMenuCtrl {
if you experience any lagging.`, if you experience any lagging.`,
destructive: true, destructive: true,
onConfirm: run onConfirm: run
}) });
} else { } else {
run(); run();
} }
@@ -99,7 +99,7 @@ class SessionHistoryMenuCtrl {
this.sessionHistory.toggleAutoOptimize().then(() => { this.sessionHistory.toggleAutoOptimize().then(() => {
this.$timeout(() => { this.$timeout(() => {
this.autoOptimize = this.sessionHistory.autoOptimize; this.autoOptimize = this.sessionHistory.autoOptimize;
}) });
}); });
} }
} }

View File

@@ -33,13 +33,13 @@ class SyncResolutionMenuCtrl {
} else { } else {
this.status.success = true; this.status.success = true;
} }
}) });
} }
close() { close() {
this.$timeout(() => { this.$timeout(() => {
this.closeFunction()(); this.closeFunction()();
}) });
} }
} }

View File

@@ -8,13 +8,13 @@ export class NoteHistoryEntry extends SFItemHistoryEntry {
previewSubTitle() { previewSubTitle() {
if(!this.hasPreviousEntry) { if(!this.hasPreviousEntry) {
return `${this.textCharDiffLength} characters loaded` return `${this.textCharDiffLength} characters loaded`;
} else if(this.textCharDiffLength < 0) { } else if(this.textCharDiffLength < 0) {
return `${this.textCharDiffLength * -1} characters removed` return `${this.textCharDiffLength * -1} characters removed`;
} else if(this.textCharDiffLength > 0) { } else if(this.textCharDiffLength > 0) {
return `${this.textCharDiffLength} characters added` return `${this.textCharDiffLength} characters added`;
} else { } else {
return "Title or metadata changed" return "Title or metadata changed";
} }
} }
} }

View File

@@ -74,7 +74,7 @@ export class ActionsManager {
if (response.actions) { if (response.actions) {
extension.actions = response.actions.map((action) => { extension.actions = response.actions.map((action) => {
return new Action(action); return new Action(action);
}) });
} else { } else {
extension.actions = []; extension.actions = [];
} }
@@ -157,7 +157,7 @@ export class ActionsManager {
const result = this.decryptResponse(response, keys); const result = this.decryptResponse(response, keys);
resolve(result); resolve(result);
}); });
}) });
} }
async handlePostAction(action, item, extension) { async handlePostAction(action, item, extension) {
@@ -183,7 +183,7 @@ export class ActionsManager {
text: "An issue occurred while processing this action. Please try again." text: "An issue occurred while processing this action. Please try again."
}); });
return { response: response }; return { response: response };
}) });
} }
async handleShowAction(action) { async handleShowAction(action) {
@@ -216,20 +216,20 @@ export class ActionsManager {
}; };
}).catch((response) => { }).catch((response) => {
const error = (response && response.error) const error = (response && response.error)
|| { message: "An issue occurred while processing this action. Please try again." } || { message: "An issue occurred while processing this action. Please try again." };
this.alertManager.alert({ text: error.message }); this.alertManager.alert({ text: error.message });
action.error = true; action.error = true;
return { error: error }; return { error: error };
}) });
} };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.alertManager.confirm({ this.alertManager.confirm({
text: "Are you sure you want to replace the current note contents with this action's results?", text: "Are you sure you want to replace the current note contents with this action's results?",
onConfirm: () => { onConfirm: () => {
onConfirm().then(resolve) onConfirm().then(resolve);
} }
}) });
}) });
} }
async handleRenderAction(action) { async handleRenderAction(action) {
@@ -250,11 +250,11 @@ export class ActionsManager {
}; };
}).catch((response) => { }).catch((response) => {
const error = (response && response.error) const error = (response && response.error)
|| { message: "An issue occurred while processing this action. Please try again." } || { message: "An issue occurred while processing this action. Please try again." };
this.alertManager.alert({ text: error.message }); this.alertManager.alert({ text: error.message });
action.error = true; action.error = true;
return { error: error }; return { error: error };
}) });
} }
async outgoingParamsForItem(item, extension, decrypted = false) { async outgoingParamsForItem(item, extension, decrypted = false) {

View File

@@ -59,7 +59,7 @@ export class ArchiveManager {
// Match up to the first parenthesis, i.e do not include '(Central Standard Time)' // Match up to the first parenthesis, i.e do not include '(Central Standard Time)'
var matches = string.match(/^(.*?) \(/); var matches = string.match(/^(.*?) \(/);
if(matches.length >= 2) { if(matches.length >= 2) {
return matches[1] return matches[1];
} }
return string; return string;
} }
@@ -113,7 +113,7 @@ export class ArchiveManager {
const fileSuffix = `-${item.uuid.split("-")[0]}.txt`; const fileSuffix = `-${item.uuid.split("-")[0]}.txt`;
// Standard max filename length is 255. Slice the note name down to allow filenameEnd // Standard max filename length is 255. Slice the note name down to allow filenameEnd
filePrefix = filePrefix.slice(0, (255 - fileSuffix.length)); filePrefix = filePrefix.slice(0, (255 - fileSuffix.length));
const fileName = `${item.content_type}/${filePrefix}${fileSuffix}` const fileName = `${item.content_type}/${filePrefix}${fileSuffix}`;
zipWriter.add(fileName, new zip.BlobReader(blob), () => { zipWriter.add(fileName, new zip.BlobReader(blob), () => {
index++; index++;
if(index < items.length) { if(index < items.length) {

View File

@@ -72,7 +72,7 @@ export class AuthManager extends SFAuthManager {
} }
return response; return response;
}) });
} }
async register(url, email, password, ephemeral) { async register(url, email, password, ephemeral) {
@@ -81,7 +81,7 @@ export class AuthManager extends SFAuthManager {
this.setEphemeral(ephemeral); this.setEphemeral(ephemeral);
} }
return response; return response;
}) });
} }
async changePassword(url, email, current_server_pw, newKeys, newAuthParams) { async changePassword(url, email, current_server_pw, newKeys, newAuthParams) {
@@ -90,7 +90,7 @@ export class AuthManager extends SFAuthManager {
this.checkForSecurityUpdate(); this.checkForSecurityUpdate();
} }
return response; return response;
}) });
} }
async handleAuthResponse(response, email, url, authParams, keys) { async handleAuthResponse(response, email, url, authParams, keys) {
@@ -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

@@ -41,13 +41,13 @@ export class DBManager {
}; };
db.onerror = function(errorEvent) { db.onerror = function(errorEvent) {
console.error("Database error: " + errorEvent.target.errorCode); console.error("Database error: " + errorEvent.target.errorCode);
} };
resolve(db); resolve(db);
}; };
request.onblocked = (event) => { request.onblocked = (event) => {
console.error("Request blocked error:", event.target.errorCode); console.error("Request blocked error:", event.target.errorCode);
} };
request.onupgradeneeded = (event) => { request.onupgradeneeded = (event) => {
const db = event.target.result; const db = event.target.result;
@@ -65,7 +65,7 @@ export class DBManager {
} }
}; };
}; };
}) });
} }
async getAllModels() { async getAllModels() {
@@ -82,7 +82,7 @@ export class DBManager {
resolve(items); resolve(items);
} }
}; };
}) });
} }
async saveModel(item) { async saveModel(item) {
@@ -92,7 +92,7 @@ export class DBManager {
async saveModels(items) { async saveModels(items) {
const showGenericError = (error) => { const showGenericError = (error) => {
this.alertManager.alert({text: `Unable to save changes locally due to an unknown system issue. Issue Code: ${error.code} Issue Name: ${error.name}.`}); this.alertManager.alert({text: `Unable to save changes locally due to an unknown system issue. Issue Code: ${error.code} Issue Name: ${error.name}.`});
} };
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
if(items.length === 0) { if(items.length === 0) {
@@ -130,17 +130,17 @@ export class DBManager {
request.onerror = (event) => { request.onerror = (event) => {
console.error("DB put error:", event.target.error); console.error("DB put error:", event.target.error);
resolve(); resolve();
} };
request.onsuccess = resolve; request.onsuccess = resolve;
}) });
} };
for(const item of items) { for(const item of items) {
await putItem(item); await putItem(item);
} }
resolve(); resolve();
}) });
} }
async deleteModel(item) { async deleteModel(item) {
@@ -149,11 +149,11 @@ export class DBManager {
const request = db.transaction("items", "readwrite").objectStore("items").delete(item.uuid); const request = db.transaction("items", "readwrite").objectStore("items").delete(item.uuid);
request.onsuccess = (event) => { request.onsuccess = (event) => {
resolve(); resolve();
} };
request.onerror = (event) => { request.onerror = (event) => {
reject(); reject();
} };
}) });
} }
async clearAllModels() { async clearAllModels() {
@@ -171,9 +171,9 @@ export class DBManager {
deleteRequest.onblocked = function(event) { deleteRequest.onblocked = function(event) {
console.error("Delete request blocked"); console.error("Delete request blocked");
this.alertManager.alert({text: "Your browser is blocking Standard Notes from deleting the local database. Make sure there are no other open windows of this app and try again. If the issue persists, please manually delete app data to sign out."}) this.alertManager.alert({text: "Your browser is blocking Standard Notes from deleting the local database. Make sure there are no other open windows of this app and try again. If the issue persists, please manually delete app data to sign out."});
resolve(); resolve();
}; };
}) });
} }
} }

View File

@@ -41,7 +41,7 @@ export class DesktopManager {
if(this.majorDataChangeHandler) { if(this.majorDataChangeHandler) {
this.majorDataChangeHandler(); this.majorDataChangeHandler();
} }
}) });
} }
saveBackup() { saveBackup() {
@@ -73,7 +73,7 @@ export class DesktopManager {
return this.convertComponentForTransmission(component); return this.convertComponentForTransmission(component);
})).then((data) => { })).then((data) => {
this.installationSyncHandler(data); this.installationSyncHandler(data);
}) });
} }
async installComponent(component) { async installComponent(component) {
@@ -216,7 +216,7 @@ export class DesktopManager {
nullOnEmpty nullOnEmpty
).then((data) => { ).then((data) => {
callback(data); callback(data);
}) });
} }
desktop_setMajorDataChangeHandler(handler) { desktop_setMajorDataChangeHandler(handler) {

View File

@@ -22,37 +22,37 @@ export class KeyboardManager {
KeyboardManager.KeyModifierCtrl, KeyboardManager.KeyModifierCtrl,
KeyboardManager.KeyModifierMeta, KeyboardManager.KeyModifierMeta,
KeyboardManager.KeyModifierAlt KeyboardManager.KeyModifierAlt
] ];
window.addEventListener('keydown', this.handleKeyDown.bind(this)); window.addEventListener('keydown', this.handleKeyDown.bind(this));
window.addEventListener('keyup', this.handleKeyUp.bind(this)); window.addEventListener('keyup', this.handleKeyUp.bind(this));
} }
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) ||
((event.shiftKey || event.key == KeyboardManager.KeyModifierShift) && modifier === KeyboardManager.KeyModifierShift) ((event.shiftKey || event.key == KeyboardManager.KeyModifierShift) && modifier === KeyboardManager.KeyModifierShift)
) );
return matches; return matches;
}) });
return eventModifiers; return eventModifiers;
} }
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

@@ -49,20 +49,20 @@ export class MigrationManager extends SFMigrationManager {
name: editor.name, name: editor.name,
area: "editor-editor" area: "editor-editor"
} }
}) });
component.setAppDataItem("data", editor.data); component.setAppDataItem("data", editor.data);
this.modelManager.addItem(component); this.modelManager.addItem(component);
this.modelManager.setItemDirty(component, true); this.modelManager.setItemDirty(component, true);
} }
} }
for(let editor of editors) { for(const editor of editors) {
this.modelManager.setItemToBeDeleted(editor); this.modelManager.setItemToBeDeleted(editor);
} }
this.syncManager.sync(); this.syncManager.sync();
} }
} };
} }
/* /*
@@ -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);
@@ -99,7 +99,7 @@ export class MigrationManager extends SFMigrationManager {
this.syncManager.sync(); this.syncManager.sync();
} }
} }
} };
} }
@@ -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);
@@ -167,6 +167,6 @@ export class MigrationManager extends SFMigrationManager {
this.statusManager.removeStatus(status); this.statusManager.removeStatus(status);
} }
} }
} };
} }
} }

View File

@@ -58,7 +58,7 @@ export class ModelManager extends SFModelManager {
if(!_.find(this.tags, {uuid: item.uuid})) { if(!_.find(this.tags, {uuid: item.uuid})) {
this.tags.splice(_.sortedIndexBy(this.tags, item, function(item){ this.tags.splice(_.sortedIndexBy(this.tags, item, function(item){
if (item.title) return item.title.toLowerCase(); if (item.title) return item.title.toLowerCase();
else return '' else return '';
}), 0, item); }), 0, item);
} }
} else if(item.content_type == "Note") { } else if(item.content_type == "Note") {
@@ -78,7 +78,7 @@ export class ModelManager extends SFModelManager {
_.pull(this.tags, tag); _.pull(this.tags, tag);
this.tags.splice(_.sortedIndexBy(this.tags, tag, function(tag){ this.tags.splice(_.sortedIndexBy(this.tags, tag, function(tag){
if (tag.title) return tag.title.toLowerCase(); if (tag.title) return tag.title.toLowerCase();
else return '' else return '';
}), 0, tag); }), 0, tag);
} }
@@ -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,16 +57,16 @@ 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
} };
var item = { var item = {
content_type: "SN|Component", content_type: "SN|Component",
@@ -84,7 +84,7 @@ export class NativeExtManager {
} }
] ]
} }
} };
if(isDesktopApplication()) { if(isDesktopApplication()) {
item.content.local_url = window._extensions_manager_location; item.content.local_url = window._extensions_manager_location;
@@ -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,16 +132,16 @@ 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
} };
var item = { var item = {
content_type: "SN|Component", content_type: "SN|Component",
@@ -161,7 +161,7 @@ export class NativeExtManager {
} }
] ]
} }
} };
if(isDesktopApplication()) { if(isDesktopApplication()) {
item.content.local_url = window._batch_manager_location; item.content.local_url = window._batch_manager_location;

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,13 +88,13 @@ 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 {
resolve(true); resolve(true);
} }
}) });
} }
unlock(passcode, callback) { unlock(passcode, callback) {
@@ -110,7 +110,7 @@ export class PasscodeManager {
this.decryptLocalStorage(keys, params).then(() => { this.decryptLocalStorage(keys, params).then(() => {
this._locked = false; this._locked = false;
callback(true); callback(true);
}) });
}); });
} }
@@ -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;
@@ -183,10 +183,10 @@ export class PasscodeManager {
// desktop only // desktop only
this.$rootScope.$on("window-lost-focus", () => { this.$rootScope.$on("window-lost-focus", () => {
this.documentVisibilityChanged(false); this.documentVisibilityChanged(false);
}) });
this.$rootScope.$on("window-gained-focus", () => { this.$rootScope.$on("window-gained-focus", () => {
this.documentVisibilityChanged(true); this.documentVisibilityChanged(true);
}) });
} else { } else {
// tab visibility listener, web only // tab visibility listener, web only
document.addEventListener('visibilitychange', (e) => { document.addEventListener('visibilitychange', (e) => {
@@ -233,7 +233,7 @@ export class PasscodeManager {
value: PasscodeManager.AutoLockIntervalOneHour, value: PasscodeManager.AutoLockIntervalOneHour,
label: "1h" label: "1h"
} }
] ];
} }
documentVisibilityChanged(visible) { documentVisibilityChanged(visible) {
@@ -264,11 +264,11 @@ 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;
} };
this.lockAfterDate = addToNow(interval / MillisecondsPerSecond); this.lockAfterDate = addToNow(interval / MillisecondsPerSecond);
this.lockTimeout = setTimeout(() => { this.lockTimeout = setTimeout(() => {

View File

@@ -50,11 +50,11 @@ export class PrivilegesManager extends SFPrivilegesManager {
const customSuccess = async () => { const customSuccess = async () => {
onSuccess && await onSuccess(); onSuccess && await onSuccess();
this.currentAuthenticationElement = null; this.currentAuthenticationElement = null;
} };
const customCancel = async () => { const customCancel = async () => {
onCancel && await onCancel(); onCancel && await onCancel();
this.currentAuthenticationElement = null; this.currentAuthenticationElement = null;
} };
const scope = this.$rootScope.$new(true); const scope = this.$rootScope.$new(true);
scope.action = action; scope.action = action;

View File

@@ -12,25 +12,25 @@ export class SessionHistory extends SFSessionHistoryManager {
) { ) {
SFItemHistory.HistoryEntryClassMapping = { SFItemHistory.HistoryEntryClassMapping = {
"Note" : NoteHistoryEntry "Note" : NoteHistoryEntry
} };
// Session History can be encrypted with passcode keys. If it changes, we need to resave session // Session History can be encrypted with passcode keys. If it changes, we need to resave session
// history with the new keys. // history with the new keys.
passcodeManager.addPasscodeChangeObserver(() => { passcodeManager.addPasscodeChangeObserver(() => {
this.saveToDisk(); this.saveToDisk();
}) });
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,
offline: offline, offline: offline,
auth_params: auth_params auth_params: auth_params
} };
} };
var contentTypes = ["Note"]; var contentTypes = ["Note"];
super( super(

View File

@@ -43,7 +43,7 @@ export class StatusManager {
result += " "; result += " ";
} }
result += status.string; result += status.string;
}) });
return result; return result;
} }

View File

@@ -147,7 +147,7 @@ export class StorageManager extends SFStorageManager {
var length = this.storage.length; var length = this.storage.length;
for(var i = 0; i < length; i++) { for(var i = 0; i < length; i++) {
var key = this.storage.key(i); var key = this.storage.key(i);
hash[key] = this.storage.getItem(key) hash[key] = this.storage.getItem(key);
} }
return hash; return hash;
} }

View File

@@ -29,14 +29,14 @@ export class ThemeManager {
// so that it's readable without authentication. // so that it's readable without authentication.
passcodeManager.addPasscodeChangeObserver(() => { passcodeManager.addPasscodeChangeObserver(() => {
this.cacheThemes(); this.cacheThemes();
}) });
if (desktopManager.isDesktop) { if (desktopManager.isDesktop) {
appState.addObserver((eventName, data) => { appState.addObserver((eventName, data) => {
if (eventName === APP_STATE_EVENT_DESKTOP_EXTS_READY) { if (eventName === APP_STATE_EVENT_DESKTOP_EXTS_READY) {
this.activateCachedThemes(); this.activateCachedThemes();
} }
}) });
} else { } else {
this.activateCachedThemes(); this.activateCachedThemes();
} }
@@ -59,7 +59,7 @@ export class ThemeManager {
this.activateTheme(component); this.activateTheme(component);
}, 10); }, 10);
} }
}) });
this.componentManager.registerHandler({ this.componentManager.registerHandler({
identifier: "themeManager", identifier: "themeManager",
@@ -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);
}); });

View File

@@ -3,7 +3,7 @@ export const STRING_SESSION_EXPIRED = "Your session has expired. New
export const STRING_DEFAULT_FILE_ERROR = "Please use FileSafe or the Bold Editor to attach images and files. Learn more at standardnotes.org/filesafe."; export const STRING_DEFAULT_FILE_ERROR = "Please use FileSafe or the Bold Editor to attach images and files. Learn more at standardnotes.org/filesafe.";
export const STRING_GENERIC_SYNC_ERROR = "There was an error syncing. Please try again. If all else fails, try signing out and signing back in."; export const STRING_GENERIC_SYNC_ERROR = "There was an error syncing. Please try again. If all else fails, try signing out and signing back in.";
export function StringSyncException(data) { export function StringSyncException(data) {
return `There was an error while trying to save your items. Please contact support and share this message: ${data}.` return `There was an error while trying to save your items. Please contact support and share this message: ${data}.`;
} }
/** @footer */ /** @footer */

View File

@@ -11,7 +11,8 @@
"bundle": "webpack --mode production", "bundle": "webpack --mode production",
"build": "bundle install && npm install && npm run bundle", "build": "bundle install && npm install && npm run bundle",
"submodules": "git submodule update --init --force --remote", "submodules": "git submodule update --init --force --remote",
"test": "karma start karma.conf.js --single-run" "test": "karma start karma.conf.js --single-run",
"lint": "eslint --fix app/assets/javascripts/**/*.js"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.8.4", "@babel/cli": "^7.8.4",