Update with latest SNJS changes
This commit is contained in:
@@ -144,5 +144,4 @@ angular
|
||||
.service('nativeExtManager', NativeExtManager)
|
||||
.service('preferencesManager', PreferencesManager)
|
||||
.service('statusManager', StatusManager)
|
||||
.service('storageManager', StorageManager)
|
||||
.service('themeManager', ThemeManager);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
SNApplication,
|
||||
SNAlertManager,
|
||||
SNAlertService,
|
||||
Environments,
|
||||
platformFromString
|
||||
} from 'snjs';
|
||||
@@ -20,7 +20,7 @@ export class Application extends SNApplication {
|
||||
deviceInterface: deviceInterface,
|
||||
swapClasses: [
|
||||
{
|
||||
swap: SNAlertManager,
|
||||
swap: SNAlertService,
|
||||
with: AlertManager
|
||||
}
|
||||
]
|
||||
|
||||
@@ -557,7 +557,7 @@ class EditorCtrl extends PureCtrl {
|
||||
}
|
||||
});
|
||||
};
|
||||
const requiresPrivilege = await this.application.privilegesManager.actionRequiresPrivilege(
|
||||
const requiresPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
|
||||
ProtectedActions.DeleteNote
|
||||
);
|
||||
if (requiresPrivilege) {
|
||||
@@ -645,7 +645,7 @@ class EditorCtrl extends PureCtrl {
|
||||
});
|
||||
|
||||
/** Show privileges manager if protection is not yet set up */
|
||||
this.application.privilegesManager.actionHasPrivilegesConfigured(
|
||||
this.application.privilegesService.actionHasPrivilegesConfigured(
|
||||
ProtectedActions.ViewProtectedNotes
|
||||
).then((configured) => {
|
||||
if (!configured) {
|
||||
|
||||
@@ -338,7 +338,7 @@ class FooterCtrl extends PureCtrl {
|
||||
};
|
||||
|
||||
if (!room.showRoom) {
|
||||
const requiresPrivilege = await this.application.privilegesManager.actionRequiresPrivilege(
|
||||
const requiresPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
|
||||
ProtectedActions.ManageExtensions
|
||||
);
|
||||
if (requiresPrivilege) {
|
||||
|
||||
@@ -287,7 +287,7 @@ class AccountMenuCtrl extends PureCtrl {
|
||||
const run = () => {
|
||||
this.godService.presentPrivilegesManagementModal();
|
||||
};
|
||||
const needsPrivilege = await this.application.privilegesManager.actionRequiresPrivilege(
|
||||
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
|
||||
ProtectedActions.ManagePrivileges
|
||||
);
|
||||
if (needsPrivilege) {
|
||||
@@ -364,7 +364,7 @@ class AccountMenuCtrl extends PureCtrl {
|
||||
await this.performImport(data, null);
|
||||
}
|
||||
};
|
||||
const needsPrivilege = await this.application.privilegesManager.actionRequiresPrivilege(
|
||||
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
|
||||
ProtectedActions.ManageBackups
|
||||
);
|
||||
if (needsPrivilege) {
|
||||
@@ -447,7 +447,7 @@ class AccountMenuCtrl extends PureCtrl {
|
||||
await this.lockManager.setAutoLockInterval(interval);
|
||||
this.reloadAutoLockInterval();
|
||||
};
|
||||
const needsPrivilege = await this.application.privilegesManager.actionRequiresPrivilege(
|
||||
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
|
||||
ProtectedActions.ManagePasscode
|
||||
);
|
||||
if (needsPrivilege) {
|
||||
@@ -493,7 +493,7 @@ class AccountMenuCtrl extends PureCtrl {
|
||||
this.state.formData.changingPasscode = true;
|
||||
this.addPasscodeClicked();
|
||||
};
|
||||
const needsPrivilege = await this.application.privilegesManager.actionRequiresPrivilege(
|
||||
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
|
||||
ProtectedActions.ManagePasscode
|
||||
);
|
||||
if (needsPrivilege) {
|
||||
@@ -521,7 +521,7 @@ class AccountMenuCtrl extends PureCtrl {
|
||||
}
|
||||
});
|
||||
};
|
||||
const needsPrivilege = await this.application.privilegesManager.actionRequiresPrivilege(
|
||||
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
|
||||
ProtectedActions.ManagePasscode
|
||||
);
|
||||
if (needsPrivilege) {
|
||||
|
||||
@@ -14,14 +14,14 @@ class PrivilegesAuthModalCtrl {
|
||||
|
||||
$onInit() {
|
||||
this.authParameters = {};
|
||||
this.sessionLengthOptions = this.application.privilegesManager.getSessionLengthOptions();
|
||||
this.application.privilegesManager.getSelectedSessionLength()
|
||||
this.sessionLengthOptions = this.application.privilegesService.getSessionLengthOptions();
|
||||
this.application.privilegesService.getSelectedSessionLength()
|
||||
.then((length) => {
|
||||
this.$timeout(() => {
|
||||
this.selectedSessionLength = length;
|
||||
});
|
||||
});
|
||||
this.application.privilegesManager.netCredentialsForAction(this.action)
|
||||
this.application.privilegesService.netCredentialsForAction(this.action)
|
||||
.then((credentials) => {
|
||||
this.$timeout(() => {
|
||||
this.requiredCredentials = credentials.sort();
|
||||
@@ -34,7 +34,7 @@ class PrivilegesAuthModalCtrl {
|
||||
}
|
||||
|
||||
promptForCredential(credential) {
|
||||
return this.application.privilegesManager.displayInfoForCredential(credential).prompt;
|
||||
return this.application.privilegesService.displayInfoForCredential(credential).prompt;
|
||||
}
|
||||
|
||||
cancel() {
|
||||
@@ -67,13 +67,13 @@ class PrivilegesAuthModalCtrl {
|
||||
if (!this.validate()) {
|
||||
return;
|
||||
}
|
||||
const result = await this.application.privilegesManager.authenticateAction(
|
||||
const result = await this.application.privilegesService.authenticateAction(
|
||||
this.action,
|
||||
this.authParameters
|
||||
);
|
||||
this.$timeout(() => {
|
||||
if (result.success) {
|
||||
this.application.privilegesManager.setSessionLength(this.selectedSessionLength);
|
||||
this.application.privilegesService.setSessionLength(this.selectedSessionLength);
|
||||
this.onSuccess();
|
||||
this.dismiss();
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@ class PrivilegesManagementModalCtrl extends PureCtrl {
|
||||
}
|
||||
|
||||
displayInfoForCredential(credential) {
|
||||
const info = this.application.privilegesManager.displayInfoForCredential(credential);
|
||||
const info = this.application.privilegesService.displayInfoForCredential(credential);
|
||||
if (credential === PrivilegeCredentials.LocalPasscode) {
|
||||
info.availability = this.hasPasscode;
|
||||
} else if (credential === PrivilegeCredentials.AccountPassword) {
|
||||
@@ -36,7 +36,7 @@ class PrivilegesManagementModalCtrl extends PureCtrl {
|
||||
}
|
||||
|
||||
displayInfoForAction(action) {
|
||||
return this.application.privilegesManager.displayInfoForAction(action).label;
|
||||
return this.application.privilegesService.displayInfoForAction(action).label;
|
||||
}
|
||||
|
||||
isCredentialRequiredForAction(action, credential) {
|
||||
@@ -47,21 +47,21 @@ class PrivilegesManagementModalCtrl extends PureCtrl {
|
||||
}
|
||||
|
||||
async clearSession() {
|
||||
await this.application.privilegesManager.clearSession();
|
||||
await this.application.privilegesService.clearSession();
|
||||
this.reloadPrivileges();
|
||||
}
|
||||
|
||||
async reloadPrivileges() {
|
||||
this.availableActions = this.application.privilegesManager.getAvailableActions();
|
||||
this.availableCredentials = this.application.privilegesManager.getAvailableCredentials();
|
||||
const sessionEndDate = await this.application.privilegesManager.getSessionExpirey();
|
||||
this.availableActions = this.application.privilegesService.getAvailableActions();
|
||||
this.availableCredentials = this.application.privilegesService.getAvailableCredentials();
|
||||
const sessionEndDate = await this.application.privilegesService.getSessionExpirey();
|
||||
this.sessionExpirey = sessionEndDate.toLocaleString();
|
||||
this.sessionExpired = new Date() >= sessionEndDate;
|
||||
this.credentialDisplayInfo = {};
|
||||
for (const cred of this.availableCredentials) {
|
||||
this.credentialDisplayInfo[cred] = this.displayInfoForCredential(cred);
|
||||
}
|
||||
const privs = await this.application.privilegesManager.getPrivileges();
|
||||
const privs = await this.application.privilegesService.getPrivileges();
|
||||
this.$timeout(() => {
|
||||
this.privileges = privs;
|
||||
});
|
||||
@@ -69,7 +69,7 @@ class PrivilegesManagementModalCtrl extends PureCtrl {
|
||||
|
||||
checkboxValueChanged(action, credential) {
|
||||
this.privileges.toggleCredentialForAction(action, credential);
|
||||
this.application.privilegesManager.savePrivileges();
|
||||
this.application.privilegesService.savePrivileges();
|
||||
}
|
||||
|
||||
cancel() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* eslint-disable prefer-promise-reject-errors */
|
||||
import { SNAlertManager } from 'snjs';
|
||||
import { SNAlertService } from 'snjs';
|
||||
import { SKAlert } from 'sn-stylekit';
|
||||
|
||||
export class AlertManager extends SNAlertManager {
|
||||
export class AlertManager extends SNAlertService {
|
||||
async alert({
|
||||
title,
|
||||
text,
|
||||
|
||||
@@ -36,7 +36,7 @@ export class ArchiveManager {
|
||||
});
|
||||
};
|
||||
|
||||
if (await this.application.privilegesManager.actionRequiresPrivilege(ProtectedActions.ManageBackups)) {
|
||||
if (await this.application.privilegesService.actionRequiresPrivilege(ProtectedActions.ManageBackups)) {
|
||||
this.godService.presentPrivilegesModal(ProtectedActions.ManageBackups, () => {
|
||||
run();
|
||||
});
|
||||
@@ -58,7 +58,7 @@ export class ArchiveManager {
|
||||
|
||||
/** @private */
|
||||
async itemsData(items, intent) {
|
||||
const data = await this.application.protocolService.createBackupFile({
|
||||
const data = await this.application.createBackupFile({
|
||||
subItems: items,
|
||||
intent: intent
|
||||
});
|
||||
|
||||
@@ -193,7 +193,7 @@ export class DesktopManager {
|
||||
}
|
||||
|
||||
async desktop_requestBackupFile(callback) {
|
||||
const data = await this.application.protocolService.createBackupFile({
|
||||
const data = await this.application.createBackupFile({
|
||||
returnIfEmpty: true
|
||||
});
|
||||
callback(data);
|
||||
|
||||
@@ -16,7 +16,7 @@ export class GodService {
|
||||
if (this.application.noAccount()) {
|
||||
return false;
|
||||
}
|
||||
const updateAvailable = await this.application.protocolService.upgradeAvailable();
|
||||
const updateAvailable = await this.application.protocolUpgradeAvailable();
|
||||
if (updateAvailable !== this.securityUpdateAvailable) {
|
||||
this.securityUpdateAvailable = updateAvailable;
|
||||
this.$rootScope.$broadcast("security-update-status-changed");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { isDesktopApplication, dictToArray } from '@/utils';
|
||||
import {
|
||||
ApplicationEvents,
|
||||
SFPredicate,
|
||||
SNPredicate,
|
||||
ContentTypes,
|
||||
CreateMaxPayloadFromAnyObject
|
||||
} from 'snjs';
|
||||
@@ -23,17 +23,17 @@ export class NativeExtManager {
|
||||
|
||||
get extManagerPred() {
|
||||
const extManagerId = 'org.standardnotes.extensions-manager';
|
||||
return SFPredicate.CompoundPredicate([
|
||||
new SFPredicate('content_type', '=', ContentTypes.Component),
|
||||
new SFPredicate('package_info.identifier', '=', extManagerId)
|
||||
return SNPredicate.CompoundPredicate([
|
||||
new SNPredicate('content_type', '=', ContentTypes.Component),
|
||||
new SNPredicate('package_info.identifier', '=', extManagerId)
|
||||
]);
|
||||
}
|
||||
|
||||
get batchManagerPred() {
|
||||
const batchMgrId = 'org.standardnotes.batch-manager';
|
||||
return SFPredicate.CompoundPredicate([
|
||||
new SFPredicate('content_type', '=', ContentTypes.Component),
|
||||
new SFPredicate('package_info.identifier', '=', batchMgrId)
|
||||
return SNPredicate.CompoundPredicate([
|
||||
new SNPredicate('content_type', '=', ContentTypes.Component),
|
||||
new SNPredicate('package_info.identifier', '=', batchMgrId)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApplicationEvents, SFPredicate, ContentTypes, CreateMaxPayloadFromAnyObject } from 'snjs';
|
||||
import { ApplicationEvents, SNPredicate, ContentTypes, CreateMaxPayloadFromAnyObject } from 'snjs';
|
||||
|
||||
export const PrefKeys = {
|
||||
TagsPanelWidth: 'tagsPanelWidth',
|
||||
@@ -42,7 +42,7 @@ export class PreferencesManager {
|
||||
|
||||
async loadSingleton() {
|
||||
const contentType = ContentTypes.UserPrefs;
|
||||
const predicate = new SFPredicate('content_type', '=', contentType);
|
||||
const predicate = new SNPredicate('content_type', '=', contentType);
|
||||
this.userPreferences = await this.application.singletonManager.findOrCreateSingleton({
|
||||
predicate: predicate,
|
||||
createPayload: CreateMaxPayloadFromAnyObject({
|
||||
|
||||
@@ -120,7 +120,7 @@ export class AppState {
|
||||
);
|
||||
};
|
||||
if (note && note.content.protected &&
|
||||
await this.application.privilegesManager.actionRequiresPrivilege(
|
||||
await this.application.privilegesService.actionRequiresPrivilege(
|
||||
ProtectedActions.ViewProtectedNotes
|
||||
)) {
|
||||
this.godService.presentPrivilegesModal(
|
||||
|
||||
Reference in New Issue
Block a user