Fixes
This commit is contained in:
@@ -14,7 +14,8 @@ import {
|
|||||||
EditorView,
|
EditorView,
|
||||||
TagsView,
|
TagsView,
|
||||||
NotesView,
|
NotesView,
|
||||||
FooterView
|
FooterView,
|
||||||
|
ChallengeModal
|
||||||
} from '@/views';
|
} from '@/views';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -32,7 +33,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
AccountMenu,
|
AccountMenu,
|
||||||
ActionsMenu,
|
ActionsMenu,
|
||||||
ChallengeModal,
|
|
||||||
ComponentModal,
|
ComponentModal,
|
||||||
ComponentView,
|
ComponentView,
|
||||||
EditorMenu,
|
EditorMenu,
|
||||||
|
|||||||
@@ -5,16 +5,14 @@ import template from '%/directives/component-modal.pug';
|
|||||||
|
|
||||||
export type ComponentModalScope = {
|
export type ComponentModalScope = {
|
||||||
componentUuid: string
|
componentUuid: string
|
||||||
callback: () => void
|
onDismiss: () => void
|
||||||
onDismiss: (component: SNComponent) => void
|
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ComponentModalCtrl implements ComponentModalScope {
|
export class ComponentModalCtrl implements ComponentModalScope {
|
||||||
$element: JQLite
|
$element: JQLite
|
||||||
componentUuid!: string
|
componentUuid!: string
|
||||||
callback!: () => void
|
onDismiss!: () => void
|
||||||
onDismiss!: (component: SNComponent) => void
|
|
||||||
application!: WebApplication
|
application!: WebApplication
|
||||||
liveComponent!: LiveItem<SNComponent>
|
liveComponent!: LiveItem<SNComponent>
|
||||||
component!: SNComponent
|
component!: SNComponent
|
||||||
@@ -41,8 +39,7 @@ export class ComponentModalCtrl implements ComponentModalScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dismiss() {
|
dismiss() {
|
||||||
this.onDismiss && this.onDismiss(this.component);
|
this.onDismiss && this.onDismiss();
|
||||||
this.callback && this.callback();
|
|
||||||
const elem = this.$element;
|
const elem = this.$element;
|
||||||
const scope = elem.scope();
|
const scope = elem.scope();
|
||||||
scope.$destroy();
|
scope.$destroy();
|
||||||
@@ -60,7 +57,6 @@ export class ComponentModal extends WebDirective {
|
|||||||
this.bindToController = true;
|
this.bindToController = true;
|
||||||
this.scope = {
|
this.scope = {
|
||||||
componentUuid: '=',
|
componentUuid: '=',
|
||||||
callback: '=',
|
|
||||||
onDismiss: '&',
|
onDismiss: '&',
|
||||||
application: '='
|
application: '='
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ class ComponentViewCtrl implements ComponentViewScope {
|
|||||||
}, avoidFlickerTimeout);
|
}, avoidFlickerTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @template */
|
||||||
public getUrl() {
|
public getUrl() {
|
||||||
const url = this.application.componentManager!.urlForComponent(this.component);
|
const url = this.application.componentManager!.urlForComponent(this.component);
|
||||||
return url;
|
return url;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
export { AccountMenu } from './accountMenu';
|
export { AccountMenu } from './accountMenu';
|
||||||
export { ActionsMenu } from './actionsMenu';
|
export { ActionsMenu } from './actionsMenu';
|
||||||
export { ChallengeModal } from './challengeModal';
|
|
||||||
export { ComponentModal } from './componentModal';
|
export { ComponentModal } from './componentModal';
|
||||||
export { ComponentView } from './componentView';
|
export { ComponentView } from './componentView';
|
||||||
export { EditorMenu } from './editorMenu';
|
export { EditorMenu } from './editorMenu';
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ export class AppState {
|
|||||||
this.registerVisibilityObservers();
|
this.registerVisibilityObservers();
|
||||||
this.addAppEventObserver();
|
this.addAppEventObserver();
|
||||||
this.streamNotesAndTags();
|
this.streamNotesAndTags();
|
||||||
|
|
||||||
const onVisibilityChange = () => {
|
const onVisibilityChange = () => {
|
||||||
const visible = document.visibilityState === "visible";
|
const visible = document.visibilityState === "visible";
|
||||||
const event = visible
|
const event = visible
|
||||||
|
|||||||
@@ -97,7 +97,11 @@ export class WebApplication extends SNApplication {
|
|||||||
(this.scope! as any).application = undefined;
|
(this.scope! as any).application = undefined;
|
||||||
this.scope!.$destroy();
|
this.scope!.$destroy();
|
||||||
this.scope = undefined;
|
this.scope = undefined;
|
||||||
super.deinit();
|
/** Allow our Angular directives to be destroyed and any pending digest cycles
|
||||||
|
* to complete before destroying the global application instance and all its services */
|
||||||
|
setImmediate(() => {
|
||||||
|
super.deinit();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
setWebServices(services: WebServices) {
|
setWebServices(services: WebServices) {
|
||||||
|
|||||||
@@ -20,14 +20,11 @@ export class ComponentGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get componentManager() {
|
get componentManager() {
|
||||||
return this.application.componentManager!;
|
return this.application?.componentManager!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public deinit() {
|
public deinit() {
|
||||||
(this.application as any) = undefined;
|
(this.application as any) = undefined;
|
||||||
for (const component of this.allActiveComponents()) {
|
|
||||||
this.componentManager.deregisterComponent(component.uuid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async activateComponent(component: SNComponent) {
|
async activateComponent(component: SNComponent) {
|
||||||
@@ -50,9 +47,15 @@ export class ComponentGroup {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
removeFromArray(this.activeComponents, component.uuid);
|
removeFromArray(this.activeComponents, component.uuid);
|
||||||
await this.componentManager.deactivateComponent(component.uuid);
|
/** If this function is called as part of global application deinit (locking),
|
||||||
if(notify) {
|
* componentManager can be destroyed. In this case, it's harmless to not take any
|
||||||
this.notifyObservers();
|
* action since the componentManager will be destroyed, and the component will
|
||||||
|
* essentially be deregistered. */
|
||||||
|
if(this.componentManager) {
|
||||||
|
await this.componentManager.deactivateComponent(component.uuid);
|
||||||
|
if(notify) {
|
||||||
|
this.notifyObservers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ export class EditorGroup {
|
|||||||
if (this.activeEditor) {
|
if (this.activeEditor) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
return () => {
|
||||||
|
removeFromArray(this.changeObservers, callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private notifyObservers() {
|
private notifyObservers() {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { WebDirective } from './../../types';
|
|
||||||
import { WebApplication } from '@/ui_models/application';
|
import { WebApplication } from '@/ui_models/application';
|
||||||
import template from '%/directives/challenge-modal.pug';
|
import template from './challenge-modal.pug';
|
||||||
import {
|
import {
|
||||||
ChallengeType,
|
ChallengeType,
|
||||||
ChallengeValue,
|
ChallengeValue,
|
||||||
@@ -9,6 +8,7 @@ import {
|
|||||||
ChallengeOrchestrator
|
ChallengeOrchestrator
|
||||||
} from 'snjs';
|
} from 'snjs';
|
||||||
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
|
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
|
||||||
|
import { WebDirective } from '@/types';
|
||||||
|
|
||||||
type InputValue = {
|
type InputValue = {
|
||||||
value: string
|
value: string
|
||||||
@@ -129,11 +129,11 @@ class ChallengeModalCtrl extends PureViewCtrl implements ChallengeModalScope {
|
|||||||
if (!this.validate()) {
|
if (!this.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setState({ processing: true });
|
await this.setState({ processing: true });
|
||||||
const values = [];
|
const values = [];
|
||||||
for (const key of Object.keys(this.getState().values)) {
|
for (const key of Object.keys(this.getState().values)) {
|
||||||
const type = Number(key) as ChallengeType;
|
const type = Number(key) as ChallengeType;
|
||||||
if (!this.getState().values[type]!.invalid) {
|
if (this.getState().values[type]!.invalid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const rawValue = this.getState().values[type]!.value;
|
const rawValue = this.getState().values[type]!.value;
|
||||||
@@ -8,7 +8,8 @@ import {
|
|||||||
SNComponent,
|
SNComponent,
|
||||||
SNTheme,
|
SNTheme,
|
||||||
ComponentArea,
|
ComponentArea,
|
||||||
ComponentAction
|
ComponentAction,
|
||||||
|
topLevelCompare
|
||||||
} from 'snjs';
|
} from 'snjs';
|
||||||
import template from './footer-view.pug';
|
import template from './footer-view.pug';
|
||||||
import { AppStateEvent, EventSource } from '@/ui_models/app_state';
|
import { AppStateEvent, EventSource } from '@/ui_models/app_state';
|
||||||
@@ -231,10 +232,13 @@ class FooterViewCtrl extends PureViewCtrl {
|
|||||||
activationHandler: () => { },
|
activationHandler: () => { },
|
||||||
actionHandler: (component, action, data) => {
|
actionHandler: (component, action, data) => {
|
||||||
if (action === ComponentAction.SetSize) {
|
if (action === ComponentAction.SetSize) {
|
||||||
this.application!.changeItem(component.uuid, (m) => {
|
/** Do comparison to avoid repetitive calls by arbitrary component */
|
||||||
const mutator = m as ComponentMutator;
|
if(!topLevelCompare(component.getLastSize(), data)) {
|
||||||
mutator.setLastSize(data);
|
this.application!.changeItem(component.uuid, (m) => {
|
||||||
})
|
const mutator = m as ComponentMutator;
|
||||||
|
mutator.setLastSize(data);
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
focusHandler: (component, focused) => {
|
focusHandler: (component, focused) => {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
export { PureViewCtrl } from './abstract/pure_view_ctrl';
|
export { PureViewCtrl } from './abstract/pure_view_ctrl';
|
||||||
|
|
||||||
export { ApplicationGroupView } from './application_group/application_group_view';
|
export { ApplicationGroupView } from './application_group/application_group_view';
|
||||||
export { ApplicationView } from './application/application_view';
|
export { ApplicationView } from './application/application_view';
|
||||||
|
|
||||||
export { EditorGroupView } from './editor_group/editor_group_view';
|
export { EditorGroupView } from './editor_group/editor_group_view';
|
||||||
export { EditorView } from './editor/editor_view';
|
export { EditorView } from './editor/editor_view';
|
||||||
|
|
||||||
export { FooterView } from './footer/footer_view';
|
export { FooterView } from './footer/footer_view';
|
||||||
export { NotesView } from './notes/notes_view';
|
export { NotesView } from './notes/notes_view';
|
||||||
export { TagsView } from './tags/tags_view';
|
export { TagsView } from './tags/tags_view';
|
||||||
|
export { ChallengeModal } from './challenge_modal/challenge_modal'
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Editor } from '@/ui_models/editor';
|
||||||
import { PanelPuppet, WebDirective } from './../../types';
|
import { PanelPuppet, WebDirective } from './../../types';
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
import template from './notes-view.pug';
|
import template from './notes-view.pug';
|
||||||
@@ -26,6 +27,7 @@ type NotesState = {
|
|||||||
panelTitle: string
|
panelTitle: string
|
||||||
notes?: SNNote[]
|
notes?: SNNote[]
|
||||||
renderedNotes?: SNNote[]
|
renderedNotes?: SNNote[]
|
||||||
|
activeEditor: Editor
|
||||||
sortBy?: string
|
sortBy?: string
|
||||||
sortReverse?: boolean
|
sortReverse?: boolean
|
||||||
showArchived?: boolean
|
showArchived?: boolean
|
||||||
@@ -62,6 +64,7 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
private previousNoteKeyObserver: any
|
private previousNoteKeyObserver: any
|
||||||
private searchKeyObserver: any
|
private searchKeyObserver: any
|
||||||
private noteFlags: Partial<Record<UuidString, NoteFlag[]>> = {}
|
private noteFlags: Partial<Record<UuidString, NoteFlag[]>> = {}
|
||||||
|
private unsubEditorChange: any
|
||||||
|
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
constructor($timeout: ng.ITimeoutService, ) {
|
constructor($timeout: ng.ITimeoutService, ) {
|
||||||
@@ -77,6 +80,11 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
this.panelPuppet = {
|
this.panelPuppet = {
|
||||||
onReady: () => this.reloadPreferences()
|
onReady: () => this.reloadPreferences()
|
||||||
};
|
};
|
||||||
|
this.unsubEditorChange = this.application.editorGroup.addChangeObserver(() => {
|
||||||
|
this.setNotesState({
|
||||||
|
activeEditor: this.application.editorGroup.activeEditor
|
||||||
|
});
|
||||||
|
})
|
||||||
this.onWindowResize = this.onWindowResize.bind(this);
|
this.onWindowResize = this.onWindowResize.bind(this);
|
||||||
this.onPanelResize = this.onPanelResize.bind(this);
|
this.onPanelResize = this.onPanelResize.bind(this);
|
||||||
window.addEventListener('resize', this.onWindowResize, true);
|
window.addEventListener('resize', this.onWindowResize, true);
|
||||||
@@ -90,6 +98,8 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
deinit() {
|
deinit() {
|
||||||
this.panelPuppet!.onReady = undefined;
|
this.panelPuppet!.onReady = undefined;
|
||||||
this.panelPuppet = undefined;
|
this.panelPuppet = undefined;
|
||||||
|
this.unsubEditorChange();
|
||||||
|
this.unsubEditorChange = undefined;
|
||||||
window.removeEventListener('resize', this.onWindowResize, true);
|
window.removeEventListener('resize', this.onWindowResize, true);
|
||||||
(this.onWindowResize as any) = undefined;
|
(this.onWindowResize as any) = undefined;
|
||||||
(this.onPanelResize as any) = undefined;
|
(this.onPanelResize as any) = undefined;
|
||||||
@@ -142,9 +152,9 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get activeEditorNote() {
|
/** @template */
|
||||||
const activeEditor = this.appState.getActiveEditor();
|
public get activeEditorNote() {
|
||||||
return activeEditor && activeEditor.note;
|
return this.getState().activeEditor?.note;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get editorNotes() {
|
public get editorNotes() {
|
||||||
|
|||||||
919
dist/javascripts/app.js
vendored
919
dist/javascripts/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/javascripts/app.js.map
vendored
2
dist/javascripts/app.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user