fix: lint errors

This commit is contained in:
Baptiste Grob
2021-01-22 11:52:24 +01:00
parent 5d65364885
commit a0909399f8
25 changed files with 74 additions and 75 deletions

View File

@@ -135,6 +135,7 @@ export class Database {
const db = (await this.openDatabase())!; const db = (await this.openDatabase())!;
const transaction = db.transaction(STORE_NAME, READ_WRITE); const transaction = db.transaction(STORE_NAME, READ_WRITE);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
transaction.oncomplete = () => { }; transaction.oncomplete = () => { };
transaction.onerror = (event) => { transaction.onerror = (event) => {
const target = event!.target! as any; const target = event!.target! as any;

View File

@@ -22,7 +22,7 @@ export function clickOutside($document: ng.IDocumentService) {
$scope.$apply(attrs.clickOutside); $scope.$apply(attrs.clickOutside);
didApplyClickOutside = true; didApplyClickOutside = true;
} }
}; }
$scope.$on('$destroy', () => { $scope.$on('$destroy', () => {
attrs.clickOutside = undefined; attrs.clickOutside = undefined;

View File

@@ -16,23 +16,23 @@ export function delayHide($timeout: ng.ITimeoutService) {
scopeAny.hidePromise = null; scopeAny.hidePromise = null;
} }
showElement(true); showElement(true);
} };
const hideSpinner = () => { const hideSpinner = () => {
scopeAny.hidePromise = $timeout( scopeAny.hidePromise = $timeout(
showElement.bind(this as any, false), showElement.bind(this as any, false),
getDelay() getDelay()
); );
} };
const showElement = (show: boolean) => { const showElement = (show: boolean) => {
show ? elem.css({ display: '' }) : elem.css({ display: 'none' }); show ? elem.css({ display: '' }) : elem.css({ display: 'none' });
} };
const getDelay = () => { const getDelay = () => {
const delay = parseInt(scopeAny.delay); const delay = parseInt(scopeAny.delay);
return angular.isNumber(delay) ? delay : 200; return angular.isNumber(delay) ? delay : 200;
} };
showElement(false); showElement(false);
// Whenever the scope variable updates we simply // Whenever the scope variable updates we simply

View File

@@ -5,7 +5,7 @@ export function elemReady($parse: ng.IParseService) {
link: function($scope: ng.IScope, elem: JQLite, attrs: any) { link: function($scope: ng.IScope, elem: JQLite, attrs: any) {
elem.ready(function() { elem.ready(function() {
$scope.$apply(function() { $scope.$apply(function() {
var func = $parse(attrs.elemReady); const func = $parse(attrs.elemReady);
func($scope); func($scope);
}); });
}); });

View File

@@ -19,7 +19,7 @@ export function infiniteScroll() {
}; };
elem.on('scroll', scopeAny.onScroll); elem.on('scroll', scopeAny.onScroll);
scope.$on('$destroy', () => { scope.$on('$destroy', () => {
elem.off('scroll', scopeAny.onScroll);; elem.off('scroll', scopeAny.onScroll);
}); });
} }
}; };

View File

@@ -140,7 +140,7 @@ class AccountMenuCtrl extends PureViewCtrl<unknown, AccountMenuState> {
syncInProgress: sync.inProgress, syncInProgress: sync.inProgress,
syncError: sync.errorMessage, syncError: sync.errorMessage,
}); });
}) });
this.removeBetaWarningListener = autorun(() => { this.removeBetaWarningListener = autorun(() => {
this.setState({ this.setState({
showBetaWarning: this.appState.showBetaWarning showBetaWarning: this.appState.showBetaWarning

View File

@@ -40,7 +40,7 @@ type ActionsMenuState = {
}[] }[]
} }
class ActionsMenuCtrl extends PureViewCtrl<{}, ActionsMenuState> implements ActionsMenuScope { class ActionsMenuCtrl extends PureViewCtrl<unknown, ActionsMenuState> implements ActionsMenuScope {
application!: WebApplication application!: WebApplication
item!: SNItem item!: SNItem
private removeHiddenExtensionsListener?: IReactionDisposer; private removeHiddenExtensionsListener?: IReactionDisposer;
@@ -63,7 +63,7 @@ class ActionsMenuCtrl extends PureViewCtrl<{}, ActionsMenuState> implements Acti
hiddenExtensions: this.appState.actionsMenu.hiddenExtensions hiddenExtensions: this.appState.actionsMenu.hiddenExtensions
}); });
}); });
}; }
deinit() { deinit() {
this.removeHiddenExtensionsListener?.(); this.removeHiddenExtensionsListener?.();
@@ -74,7 +74,7 @@ class ActionsMenuCtrl extends PureViewCtrl<{}, ActionsMenuState> implements Acti
const extensions = this.application.actionsManager!.getExtensions().sort((a, b) => { const extensions = this.application.actionsManager!.getExtensions().sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
}); });
let extensionsState: Record<UuidString, ExtensionState> = {}; const extensionsState: Record<UuidString, ExtensionState> = {};
extensions.map((extension) => { extensions.map((extension) => {
extensionsState[extension.uuid] = { extensionsState[extension.uuid] = {
loading: false, loading: false,
@@ -114,7 +114,7 @@ class ActionsMenuCtrl extends PureViewCtrl<{}, ActionsMenuState> implements Acti
return { return {
...action, ...action,
subrows: this.subRowsForAction(action, extension) subrows: this.subRowsForAction(action, extension)
} };
} else { } else {
return action; return action;
} }

View File

@@ -159,7 +159,7 @@ class ComponentViewCtrl implements ComponentViewScope {
this.$timeout(() => { this.$timeout(() => {
this.reloading = false; this.reloading = false;
}); });
}) });
} }
private onVisibilityChange() { private onVisibilityChange() {
@@ -228,6 +228,7 @@ class ComponentViewCtrl implements ComponentViewScope {
if (!iframe.contentWindow!.origin || iframe.contentWindow!.origin === 'null') { if (!iframe.contentWindow!.origin || iframe.contentWindow!.origin === 'null') {
desktopError = true; desktopError = true;
} }
// eslint-disable-next-line no-empty
} catch (e) { } } catch (e) { }
} }
this.$timeout.cancel(this.loadTimeout); this.$timeout.cancel(this.loadTimeout);

View File

@@ -52,14 +52,14 @@ class EditorMenuCtrl extends PureViewCtrl implements EditorMenuScope {
editors: editors, editors: editors,
defaultEditor: defaultEditor defaultEditor: defaultEditor
}); });
}; }
selectComponent(component: SNComponent) { selectComponent(component: SNComponent) {
if (component) { if (component) {
if (component.conflictOf) { if (component.conflictOf) {
this.application.changeAndSaveItem(component.uuid, (mutator) => { this.application.changeAndSaveItem(component.uuid, (mutator) => {
mutator.conflictOf = undefined; mutator.conflictOf = undefined;
}) });
} }
} }
this.$timeout(() => { this.$timeout(() => {
@@ -87,7 +87,7 @@ class EditorMenuCtrl extends PureViewCtrl implements EditorMenuScope {
this.application.changeItem(currentDefault.uuid, (m) => { this.application.changeItem(currentDefault.uuid, (m) => {
const mutator = m as ComponentMutator; const mutator = m as ComponentMutator;
mutator.defaultEditor = false; mutator.defaultEditor = false;
}) });
} }
this.application.changeAndSaveItem(component.uuid, (m) => { this.application.changeAndSaveItem(component.uuid, (m) => {
const mutator = m as ComponentMutator; const mutator = m as ComponentMutator;

View File

@@ -16,7 +16,7 @@ interface HistoryScope {
item: SNItem item: SNItem
} }
class HistoryMenuCtrl extends PureViewCtrl<{}, HistoryState> implements HistoryScope { class HistoryMenuCtrl extends PureViewCtrl<unknown, HistoryState> implements HistoryScope {
diskEnabled = false diskEnabled = false
autoOptimize = false autoOptimize = false

View File

@@ -6,12 +6,12 @@ import { debounce } from '@/utils';
enum PanelSide { enum PanelSide {
Right = 'right', Right = 'right',
Left = 'left' Left = 'left'
}; }
enum MouseEventType { enum MouseEventType {
Move = 'mousemove', Move = 'mousemove',
Down = 'mousedown', Down = 'mousedown',
Up = 'mouseup' Up = 'mouseup'
}; }
enum CssClass { enum CssClass {
Hoverable = 'hoverable', Hoverable = 'hoverable',
AlwaysVisible = 'always-visible', AlwaysVisible = 'always-visible',
@@ -19,7 +19,7 @@ enum CssClass {
NoSelection = 'no-selection', NoSelection = 'no-selection',
Collapsed = 'collapsed', Collapsed = 'collapsed',
AnimateOpacity = 'animate-opacity', AnimateOpacity = 'animate-opacity',
}; }
const WINDOW_EVENT_RESIZE = 'resize'; const WINDOW_EVENT_RESIZE = 'resize';
type ResizeFinishCallback = ( type ResizeFinishCallback = (

View File

@@ -7,7 +7,7 @@ const DEFAULT_CONTINUE_TITLE = "Continue";
enum Steps { enum Steps {
PasswordStep = 1, PasswordStep = 1,
FinishStep = 2 FinishStep = 2
}; }
type FormData = { type FormData = {
currentPassword?: string, currentPassword?: string,

View File

@@ -15,5 +15,4 @@ import '../../../vendor/assets/javascripts/zip/zip';
import '../../../vendor/assets/javascripts/zip/z-worker'; import '../../../vendor/assets/javascripts/zip/z-worker';
// entry point // entry point
// eslint-disable-next-line import/first
import './app'; import './app';

View File

@@ -13,7 +13,7 @@ export const STRING_NEW_UPDATE_READY = "A new update is ready to install. Please
export const STRING_DELETE_TAG = "Are you sure you want to delete this tag? Note: deleting a tag will not delete its notes."; export const STRING_DELETE_TAG = "Are you sure you want to delete this tag? Note: deleting a tag will not delete its notes.";
/** @editor */ /** @editor */
export const STRING_SAVING_WHILE_DOCUMENT_HIDDEN = 'Attempting to save an item while the application is hidden. To protect data integrity, please refresh the application window and try again.' export const STRING_SAVING_WHILE_DOCUMENT_HIDDEN = 'Attempting to save an item while the application is hidden. To protect data integrity, please refresh the application window and try again.';
export const STRING_DELETED_NOTE = "The note you are attempting to edit has been deleted, and is awaiting sync. Changes you make will be disregarded."; export const STRING_DELETED_NOTE = "The note you are attempting to edit has been deleted, and is awaiting sync. Changes you make will be disregarded.";
export const STRING_INVALID_NOTE = "The note you are attempting to save can not be found or has been deleted. Changes you make will not be synced. Please copy this note's text and start a new note."; export const STRING_INVALID_NOTE = "The note you are attempting to save can not be found or has been deleted. Changes you make will not be synced. Please copy this note's text and start a new note.";
export const STRING_ELLIPSES = "..."; export const STRING_ELLIPSES = "...";
@@ -56,15 +56,15 @@ export const STRING_FAILED_PASSWORD_CHANGE = "There was an error re-encrypting y
export const STRING_CONFIRM_APP_QUIT_DURING_UPGRADE = export const STRING_CONFIRM_APP_QUIT_DURING_UPGRADE =
"The encryption upgrade is in progress. You may lose data if you quit the app. " + "The encryption upgrade is in progress. You may lose data if you quit the app. " +
"Are you sure you want to quit?" "Are you sure you want to quit?";
export const STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_CHANGE = export const STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_CHANGE =
"A passcode change is in progress. You may lose data if you quit the app. " + "A passcode change is in progress. You may lose data if you quit the app. " +
"Are you sure you want to quit?" "Are you sure you want to quit?";
export const STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL = export const STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL =
"A passcode removal is in progress. You may lose data if you quit the app. " + "A passcode removal is in progress. You may lose data if you quit the app. " +
"Are you sure you want to quit?" "Are you sure you want to quit?";
export const STRING_UPGRADE_ACCOUNT_CONFIRM_TITLE = 'Encryption upgrade available'; export const STRING_UPGRADE_ACCOUNT_CONFIRM_TITLE = 'Encryption upgrade available';
export const STRING_UPGRADE_ACCOUNT_CONFIRM_TEXT = export const STRING_UPGRADE_ACCOUNT_CONFIRM_TEXT =

View File

@@ -50,7 +50,9 @@ export function dateToLocalizedString(date: Date) {
export function debounce(this: any, func: any, wait: number, immediate = false) { export function debounce(this: any, func: any, wait: number, immediate = false) {
let timeout: any; let timeout: any;
return () => { return () => {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this; const context = this;
// eslint-disable-next-line prefer-rest-params
const args = arguments; const args = arguments;
const later = function () { const later = function () {
timeout = null; timeout = null;
@@ -61,7 +63,7 @@ export function debounce(this: any, func: any, wait: number, immediate = false)
timeout = setTimeout(later, wait); timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args); if (callNow) func.apply(context, args);
}; };
}; }
// https://tc39.github.io/ecma262/#sec-array.prototype.includes // https://tc39.github.io/ecma262/#sec-array.prototype.includes
if (!Array.prototype.includes) { if (!Array.prototype.includes) {
@@ -73,10 +75,10 @@ if (!Array.prototype.includes) {
} }
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
var o = Object(this); const o = Object(this);
// 2. Let len be ? ToLength(? Get(O, "length")). // 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0; const len = o.length >>> 0;
// 3. If len is 0, return false. // 3. If len is 0, return false.
if (len === 0) { if (len === 0) {
@@ -85,14 +87,14 @@ if (!Array.prototype.includes) {
// 4. Let n be ? ToInteger(fromIndex). // 4. Let n be ? ToInteger(fromIndex).
// (If fromIndex is undefined, this step produces the value 0.) // (If fromIndex is undefined, this step produces the value 0.)
var n = fromIndex | 0; const n = fromIndex | 0;
// 5. If n ≥ 0, then // 5. If n ≥ 0, then
// a. Let k be n. // a. Let k be n.
// 6. Else n < 0, // 6. Else n < 0,
// a. Let k be len + n. // a. Let k be len + n.
// b. If k < 0, let k be 0. // b. If k < 0, let k be 0.
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); let k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
function sameValueZero(x: number, y: number) { function sameValueZero(x: number, y: number) {
return ( return (

View File

@@ -30,7 +30,7 @@ export class PureViewCtrl<P = CtrlProps, S = CtrlState> {
this.state = { this.state = {
...this.getInitialState(), ...this.getInitialState(),
...this.state, ...this.state,
} };
this.addAppEventObserver(); this.addAppEventObserver();
this.addAppStateObserver(); this.addAppStateObserver();
this.templateReady = true; this.templateReady = true;
@@ -83,7 +83,8 @@ export class PureViewCtrl<P = CtrlProps, S = CtrlState> {
} }
/** @override */ /** @override */
afterStateChange() { // eslint-disable-next-line @typescript-eslint/no-empty-function
afterStateChange(): void {
} }
/** @returns a promise that resolves after the UI has been updated. */ /** @returns a promise that resolves after the UI has been updated. */

View File

@@ -7,7 +7,7 @@ import {
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl'; import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
import { WebDirective } from '@/types'; import { WebDirective } from '@/types';
class AccountSwitcherCtrl extends PureViewCtrl<{}, { class AccountSwitcherCtrl extends PureViewCtrl<unknown, {
descriptors: ApplicationDescriptor[]; descriptors: ApplicationDescriptor[];
editingDescriptor?: ApplicationDescriptor editingDescriptor?: ApplicationDescriptor
}> { }> {
@@ -38,7 +38,7 @@ class AccountSwitcherCtrl extends PureViewCtrl<{}, {
reloadApplications() { reloadApplications() {
this.setState({ this.setState({
descriptors: this.mainApplicationGroup.getDescriptors() descriptors: this.mainApplicationGroup.getDescriptors()
}) });
} }
/** @template */ /** @template */
@@ -63,7 +63,7 @@ class AccountSwitcherCtrl extends PureViewCtrl<{}, {
this.setState({ editingDescriptor: descriptor }).then(() => { this.setState({ editingDescriptor: descriptor }).then(() => {
const input = this.inputForDescriptor(descriptor); const input = this.inputForDescriptor(descriptor);
input?.focus(); input?.focus();
}) });
} }
/** @template */ /** @template */
@@ -71,7 +71,7 @@ class AccountSwitcherCtrl extends PureViewCtrl<{}, {
this.mainApplicationGroup.renameDescriptor( this.mainApplicationGroup.renameDescriptor(
this.state.editingDescriptor!, this.state.editingDescriptor!,
this.state.editingDescriptor!.label this.state.editingDescriptor!.label
) );
this.setState({ editingDescriptor: undefined }); this.setState({ editingDescriptor: undefined });
} }

View File

@@ -94,7 +94,7 @@ class ApplicationViewCtrl extends PureViewCtrl<unknown, {
onUpdateAvailable() { onUpdateAvailable() {
this.$rootScope!.$broadcast(RootScopeMessages.NewUpdateAvailable); this.$rootScope!.$broadcast(RootScopeMessages.NewUpdateAvailable);
}; }
/** @override */ /** @override */
async onAppEvent(eventName: ApplicationEvent) { async onAppEvent(eventName: ApplicationEvent) {

View File

@@ -142,7 +142,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
this.onPanelResizeFinish = this.onPanelResizeFinish.bind(this); this.onPanelResizeFinish = this.onPanelResizeFinish.bind(this);
this.onEditorLoad = () => { this.onEditorLoad = () => {
this.application!.getDesktopService().redoSearch(); this.application!.getDesktopService().redoSearch();
} };
} }
deinit() { deinit() {
@@ -199,7 +199,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
if (note.lastSyncBegan) { if (note.lastSyncBegan) {
if (note.lastSyncEnd) { if (note.lastSyncEnd) {
if (note.lastSyncBegan!.getTime() > note.lastSyncEnd!.getTime()) { if (note.lastSyncBegan!.getTime() > note.lastSyncEnd!.getTime()) {
this.showSavingStatus() this.showSavingStatus();
} else if (note.lastSyncEnd!.getTime() > note.lastSyncBegan!.getTime()) { } else if (note.lastSyncEnd!.getTime() > note.lastSyncBegan!.getTime()) {
this.showAllChangesSavedStatus(); this.showAllChangesSavedStatus();
} }
@@ -412,7 +412,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
await this.application.changeItem(this.note.uuid, (mutator) => { await this.application.changeItem(this.note.uuid, (mutator) => {
const noteMutator = mutator as NoteMutator; const noteMutator = mutator as NoteMutator;
noteMutator.prefersPlainEditor = false; noteMutator.prefersPlainEditor = false;
}) });
} }
await this.associateComponentWithCurrentNote(component); await this.associateComponentWithCurrentNote(component);
} }
@@ -471,7 +471,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
(mutator) => { (mutator) => {
mutator.addItemAsRelationship(note); mutator.addItemAsRelationship(note);
} }
) );
} }
if (!this.application.findItem(note.uuid)) { if (!this.application.findItem(note.uuid)) {
this.application.alertService!.alert( this.application.alertService!.alert(
@@ -494,7 +494,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
noteMutator.preview_plain = previewPlain; noteMutator.preview_plain = previewPlain;
noteMutator.preview_html = undefined; noteMutator.preview_html = undefined;
} }
}, isUserModified) }, isUserModified);
if (this.saveTimeout) { if (this.saveTimeout) {
this.$timeout.cancel(this.saveTimeout); this.$timeout.cancel(this.saveTimeout);
} }
@@ -549,7 +549,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
this.statusTimeout = this.$timeout(() => { this.statusTimeout = this.$timeout(() => {
this.setState({ this.setState({
noteStatus: status noteStatus: status
}) });
}, MINIMUM_STATUS_DURATION); }, MINIMUM_STATUS_DURATION);
} else { } else {
this.setState({ this.setState({
@@ -702,7 +702,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false, false,
true, true,
(mutator) => { (mutator) => {
mutator.pinned = !this.note.pinned mutator.pinned = !this.note.pinned;
} }
); );
} }
@@ -713,7 +713,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false, false,
true, true,
(mutator) => { (mutator) => {
mutator.locked = !this.note.locked mutator.locked = !this.note.locked;
} }
); );
} }
@@ -724,7 +724,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false, false,
true, true,
(mutator) => { (mutator) => {
mutator.protected = !this.note.protected mutator.protected = !this.note.protected;
} }
); );
} }
@@ -735,7 +735,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false, false,
true, true,
(mutator) => { (mutator) => {
mutator.hidePreview = !this.note.hidePreview mutator.hidePreview = !this.note.hidePreview;
} }
); );
} }
@@ -754,7 +754,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false, false,
true, true,
(mutator) => { (mutator) => {
mutator.archived = !this.note.archived mutator.archived = !this.note.archived;
}, },
/** If we are unarchiving, and we are in the archived tag, close the editor */ /** If we are unarchiving, and we are in the archived tag, close the editor */
this.note.archived && this.appState.selectedTag?.isArchiveTag this.note.archived && this.appState.selectedTag?.isArchiveTag
@@ -863,7 +863,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
(mutator) => { (mutator) => {
mutator.addItemAsRelationship(note); mutator.addItemAsRelationship(note);
} }
) );
} }
this.application.sync(); this.application.sync();
this.reloadTags(); this.reloadTags();
@@ -970,7 +970,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
); );
await this.setState({ await this.setState({
[key]: !currentValue [key]: !currentValue
}) });
this.reloadFont(); this.reloadFont();
if (key === PrefKey.EditorSpellcheck) { if (key === PrefKey.EditorSpellcheck) {
@@ -1061,7 +1061,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
(mutator) => { (mutator) => {
mutator.addItemAsRelationship(this.note); mutator.addItemAsRelationship(this.note);
} }
) );
} }
} }
} }
@@ -1120,7 +1120,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
const mutator = m as ComponentMutator; const mutator = m as ComponentMutator;
mutator.removeAssociatedItemId(note.uuid); mutator.removeAssociatedItemId(note.uuid);
mutator.disassociateWithItem(note.uuid); mutator.disassociateWithItem(note.uuid);
}) });
} }
async associateComponentWithCurrentNote(component: SNComponent) { async associateComponentWithCurrentNote(component: SNComponent) {
@@ -1129,7 +1129,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
const mutator = m as ComponentMutator; const mutator = m as ComponentMutator;
mutator.removeDisassociatedItemId(note.uuid); mutator.removeDisassociatedItemId(note.uuid);
mutator.associateWithItem(note.uuid); mutator.associateWithItem(note.uuid);
}) });
} }
registerKeyboardShortcuts() { registerKeyboardShortcuts() {

View File

@@ -8,15 +8,10 @@ class EditorGroupViewCtrl {
private application!: WebApplication private application!: WebApplication
public editors: Editor[] = [] public editors: Editor[] = []
/* @ngInject */
constructor() {
}
$onInit() { $onInit() {
this.application.editorGroup.addChangeObserver(() => { this.application.editorGroup.addChangeObserver(() => {
this.editors = this.application.editorGroup.editors; this.editors = this.application.editorGroup.editors;
}) });
} }
} }

View File

@@ -208,7 +208,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
break; break;
case AppStateEvent.EndedBackupDownload: { case AppStateEvent.EndedBackupDownload: {
const successMessage = "Successfully saved backup."; const successMessage = "Successfully saved backup.";
const errorMessage = "Unable to save local backup." const errorMessage = "Unable to save local backup.";
statusService.setMessage(data.success ? successMessage : errorMessage); statusService.setMessage(data.success ? successMessage : errorMessage);
const twoSeconds = 2000; const twoSeconds = 2000;
@@ -297,7 +297,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
theme.package_info.dock_icon theme.package_info.dock_icon
); );
} }
) );
this.observerRemovers.push(this.application.streamItems( this.observerRemovers.push(this.application.streamItems(
ContentType.Component, ContentType.Component,

View File

@@ -7,7 +7,7 @@ export function notePassesFilter(
filterText: string filterText: string
) { ) {
let canShowArchived = showArchived; const canShowArchived = showArchived;
const canShowPinned = !hidePinned; const canShowPinned = !hidePinned;
if ( if (
(note.archived && !canShowArchived) || (note.archived && !canShowArchived) ||

View File

@@ -59,7 +59,7 @@ const DEFAULT_LIST_NUM_NOTES = 20;
const ELEMENT_ID_SEARCH_BAR = 'search-bar'; const ELEMENT_ID_SEARCH_BAR = 'search-bar';
const ELEMENT_ID_SCROLL_CONTAINER = 'notes-scrollable'; const ELEMENT_ID_SCROLL_CONTAINER = 'notes-scrollable';
class NotesViewCtrl extends PureViewCtrl<{}, NotesState> { class NotesViewCtrl extends PureViewCtrl<unknown, NotesState> {
private panelPuppet?: PanelPuppet private panelPuppet?: PanelPuppet
private reloadNotesPromise?: any private reloadNotesPromise?: any
@@ -410,7 +410,7 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
if (activeNote && activeNote.conflictOf) { if (activeNote && activeNote.conflictOf) {
this.application!.changeAndSaveItem(activeNote.uuid, (mutator) => { this.application!.changeAndSaveItem(activeNote.uuid, (mutator) => {
mutator.conflictOf = undefined; mutator.conflictOf = undefined;
}) });
} }
if (this.isFiltering()) { if (this.isFiltering()) {
this.application!.getDesktopService().searchText(this.getState().noteFilter.text); this.application!.getDesktopService().searchText(this.getState().noteFilter.text);
@@ -641,7 +641,7 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
selectNextNote() { selectNextNote() {
const displayableNotes = this.displayableNotes(); const displayableNotes = this.displayableNotes();
const currentIndex = displayableNotes.findIndex((candidate) => { const currentIndex = displayableNotes.findIndex((candidate) => {
return candidate.uuid === this.activeEditorNote!.uuid return candidate.uuid === this.activeEditorNote!.uuid;
}); });
if (currentIndex + 1 < displayableNotes.length) { if (currentIndex + 1 < displayableNotes.length) {
this.selectNote(displayableNotes[currentIndex + 1]); this.selectNote(displayableNotes[currentIndex + 1]);
@@ -798,7 +798,7 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
], ],
onKeyDown: () => { onKeyDown: () => {
const searchBar = this.getSearchBar(); const searchBar = this.getSearchBar();
if (searchBar) { searchBar.focus(); }; if (searchBar) { searchBar.focus(); }
} }
}); });
} }

View File

@@ -36,7 +36,7 @@ type TagState = {
templateTag?: SNTag templateTag?: SNTag
} }
class TagsViewCtrl extends PureViewCtrl<{}, TagState> { class TagsViewCtrl extends PureViewCtrl<unknown, TagState> {
/** Passed through template */ /** Passed through template */
readonly application!: WebApplication readonly application!: WebApplication
@@ -136,7 +136,7 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
} else { } else {
this.setState({ this.setState({
selectedTag: matchingTag selectedTag: matchingTag
}) });
} }
} }
} }
@@ -186,14 +186,14 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
const notes = this.application.notesMatchingSmartTag(tag as SNSmartTag) const notes = this.application.notesMatchingSmartTag(tag as SNSmartTag)
.filter((note) => { .filter((note) => {
return !note.archived && !note.trashed; return !note.archived && !note.trashed;
}) });
noteCounts[tag.uuid] = notes.length; noteCounts[tag.uuid] = notes.length;
} }
} else { } else {
const notes = this.application.referencesForItem(tag, ContentType.Note) const notes = this.application.referencesForItem(tag, ContentType.Note)
.filter((note) => { .filter((note) => {
return !note.archived && !note.trashed; return !note.archived && !note.trashed;
}) });
noteCounts[tag.uuid] = notes.length; noteCounts[tag.uuid] = notes.length;
} }
} }
@@ -264,7 +264,7 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
if (tag.conflictOf) { if (tag.conflictOf) {
this.application.changeAndSaveItem(tag.uuid, (mutator) => { this.application.changeAndSaveItem(tag.uuid, (mutator) => {
mutator.conflictOf = undefined; mutator.conflictOf = undefined;
}) });
} }
this.application.getAppState().setSelectedTag(tag); this.application.getAppState().setSelectedTag(tag);
} }
@@ -326,7 +326,7 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
"A tag with this name already exists." "A tag with this name already exists."
); );
return; return;
}; }
await this.application.changeAndSaveItem<TagMutator>(tag.uuid, (mutator) => { await this.application.changeAndSaveItem<TagMutator>(tag.uuid, (mutator) => {
mutator.title = newTitle; mutator.title = newTitle;
}); });
@@ -350,7 +350,7 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
"A tag with this name already exists." "A tag with this name already exists."
); );
return; return;
}; }
const insertedTag = await this.application.insertItem(newTag); const insertedTag = await this.application.insertItem(newTag);
const changedTag = await this.application.changeItem<TagMutator>(insertedTag.uuid, (m) => { const changedTag = await this.application.changeItem<TagMutator>(insertedTag.uuid, (m) => {
m.title = newTitle; m.title = newTitle;

View File

@@ -16,7 +16,7 @@
"bundle:desktop:beta": "webpack --config webpack.prod.js --env.platform='desktop' --env.public_beta='true'", "bundle:desktop:beta": "webpack --config webpack.prod.js --env.platform='desktop' --env.public_beta='true'",
"build": "bundle install && yarn install --pure-lockfile && bundle exec rails assets:precompile && yarn bundle", "build": "bundle install && yarn install --pure-lockfile && bundle exec rails assets:precompile && yarn bundle",
"submodules": "git submodule update --init --force", "submodules": "git submodule update --init --force",
"lint": "eslint --fix app/assets/javascripts/**/*.{ts,tsx}", "lint": "eslint --fix app/assets/javascripts",
"tsc": "tsc --project app/assets/javascripts/tsconfig.json" "tsc": "tsc --project app/assets/javascripts/tsconfig.json"
}, },
"devDependencies": { "devDependencies": {