wip: server history support
This commit is contained in:
@@ -44,7 +44,7 @@ import {
|
||||
PrivilegesAuthModal,
|
||||
PrivilegesManagementModal,
|
||||
RevisionPreviewModal,
|
||||
SessionHistoryMenu,
|
||||
HistoryMenu,
|
||||
SyncResolutionMenu
|
||||
} from './directives/views';
|
||||
|
||||
@@ -100,7 +100,7 @@ angular
|
||||
.directive('privilegesAuthModal', () => new PrivilegesAuthModal())
|
||||
.directive('privilegesManagementModal', () => new PrivilegesManagementModal())
|
||||
.directive('revisionPreviewModal', () => new RevisionPreviewModal())
|
||||
.directive('sessionHistoryMenu', () => new SessionHistoryMenu())
|
||||
.directive('historyMenu', () => new HistoryMenu())
|
||||
.directive('syncResolutionMenu', () => new SyncResolutionMenu());
|
||||
|
||||
// Filters
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import { WebDirective } from './../../types';
|
||||
import { WebDirective } from '../../types';
|
||||
import { WebApplication } from '@/ui_models/application';
|
||||
import template from '%/directives/session-history-menu.pug';
|
||||
import template from '%/directives/history-menu.pug';
|
||||
import { SNItem, ItemHistoryEntry, ItemHistory } from '@node_modules/snjs/dist/@types';
|
||||
import { PayloadSource } from 'snjs';
|
||||
|
||||
interface SessionHistoryScope {
|
||||
interface HistoryScope {
|
||||
application: WebApplication
|
||||
item: SNItem
|
||||
}
|
||||
|
||||
class SessionHistoryMenuCtrl implements SessionHistoryScope {
|
||||
class HistoryMenuCtrl implements HistoryScope {
|
||||
|
||||
$timeout: ng.ITimeoutService
|
||||
diskEnabled = false
|
||||
autoOptimize = false
|
||||
fetchingServerHistory = false
|
||||
application!: WebApplication
|
||||
item!: SNItem
|
||||
entries!: ItemHistoryEntry[]
|
||||
history!: ItemHistory
|
||||
|
||||
/* @ngInject */
|
||||
@@ -31,12 +32,8 @@ class SessionHistoryMenuCtrl implements SessionHistoryScope {
|
||||
this.autoOptimize = this.application.historyManager!.isAutoOptimizeEnabled();
|
||||
}
|
||||
|
||||
reloadHistory() {
|
||||
const history = this.application.historyManager!.historyForItem(this.item);
|
||||
this.entries = history.entries.slice(0).sort((a, b) => {
|
||||
return a.payload.updated_at! < b.payload.updated_at! ? 1 : -1;
|
||||
});
|
||||
this.history = history;
|
||||
async reloadHistory() {
|
||||
this.history = await this.application.historyManager!.historyForItem(this.item);
|
||||
}
|
||||
|
||||
openRevision(revision: ItemHistoryEntry) {
|
||||
@@ -93,6 +90,18 @@ class SessionHistoryMenuCtrl implements SessionHistoryScope {
|
||||
);
|
||||
}
|
||||
|
||||
get historySessionEntries() {
|
||||
return this.history.entries.filter((entry) => {
|
||||
return entry.payload.source === PayloadSource.SessionHistory;
|
||||
});
|
||||
}
|
||||
|
||||
get historyServerEntries() {
|
||||
return this.history.entries.filter((entry) => {
|
||||
return entry.payload.source === PayloadSource.ServerHistory;
|
||||
});
|
||||
}
|
||||
|
||||
toggleDiskSaving() {
|
||||
const run = () => {
|
||||
this.application.historyManager!.toggleDiskSaving().then(() => {
|
||||
@@ -125,14 +134,20 @@ class SessionHistoryMenuCtrl implements SessionHistoryScope {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fetchServerHistory() {
|
||||
this.fetchingServerHistory = true;
|
||||
this.reloadHistory();
|
||||
this.fetchingServerHistory = false;
|
||||
}
|
||||
}
|
||||
|
||||
export class SessionHistoryMenu extends WebDirective {
|
||||
export class HistoryMenu extends WebDirective {
|
||||
constructor() {
|
||||
super();
|
||||
this.restrict = 'E';
|
||||
this.template = template;
|
||||
this.controller = SessionHistoryMenuCtrl;
|
||||
this.controller = HistoryMenuCtrl;
|
||||
this.controllerAs = 'ctrl';
|
||||
this.bindToController = true;
|
||||
this.scope = {
|
||||
@@ -11,5 +11,5 @@ export { PermissionsModal } from './permissionsModal';
|
||||
export { PrivilegesAuthModal } from './privilegesAuthModal';
|
||||
export { PrivilegesManagementModal } from './privilegesManagementModal';
|
||||
export { RevisionPreviewModal } from './revisionPreviewModal';
|
||||
export { SessionHistoryMenu } from './sessionHistoryMenu';
|
||||
export { HistoryMenu } from './historyMenu';
|
||||
export { SyncResolutionMenu } from './syncResolutionMenu';
|
||||
|
||||
@@ -183,14 +183,14 @@
|
||||
application='self.application'
|
||||
)
|
||||
.sk-app-bar-item(
|
||||
click-outside=`self.setMenuState('showSessionHistory', false)`,
|
||||
is-open='self.state.showSessionHistory',
|
||||
ng-click="self.toggleMenu('showSessionHistory')"
|
||||
click-outside=`self.setMenuState('showHistory', false)`,
|
||||
is-open='self.state.showHistory',
|
||||
ng-click="self.toggleMenu('showHistory')"
|
||||
)
|
||||
.sk-label Session History
|
||||
session-history-menu(
|
||||
.sk-label History
|
||||
history-menu(
|
||||
item='self.note',
|
||||
ng-if='self.state.showSessionHistory',
|
||||
ng-if='self.state.showHistory',
|
||||
application='self.application'
|
||||
)
|
||||
#editor-content.editor-content(ng-if='!self.note.errorDecrypting')
|
||||
|
||||
Reference in New Issue
Block a user