Update SNJS

This commit is contained in:
Mo Bitar
2020-03-14 11:06:03 -05:00
parent 444c18bbde
commit 8fcfef08a6
22 changed files with 89726 additions and 68 deletions

View File

@@ -5,7 +5,7 @@ import {
platformFromString platformFromString
} from 'snjs'; } from 'snjs';
import { getPlatformString } from '@/utils'; import { getPlatformString } from '@/utils';
import { AlertManager } from '@/services/alertManager'; import { AlertService } from '@/services/alertService';
import { WebDeviceInterface } from '@/web_device_interface'; import { WebDeviceInterface } from '@/web_device_interface';
export class Application extends SNApplication { export class Application extends SNApplication {
@@ -21,7 +21,7 @@ export class Application extends SNApplication {
swapClasses: [ swapClasses: [
{ {
swap: SNAlertService, swap: SNAlertService,
with: AlertManager with: AlertService
} }
] ]
}); });

View File

@@ -369,13 +369,13 @@ class EditorCtrl extends PureCtrl {
const note = this.state.note; const note = this.state.note;
note.dummy = false; note.dummy = false;
if (note.deleted) { if (note.deleted) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_DELETED_NOTE text: STRING_DELETED_NOTE
}); });
return; return;
} }
if (!this.application.findItem({ uuid: note.uuid })) { if (!this.application.findItem({ uuid: note.uuid })) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_INVALID_NOTE text: STRING_INVALID_NOTE
}); });
return; return;
@@ -520,14 +520,14 @@ class EditorCtrl extends PureCtrl {
async deleteNote(permanently) { async deleteNote(permanently) {
if (this.state.note.dummy) { if (this.state.note.dummy) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_DELETE_PLACEHOLDER_ATTEMPT text: STRING_DELETE_PLACEHOLDER_ATTEMPT
}); });
return; return;
} }
const run = () => { const run = () => {
if (this.state.note.locked) { if (this.state.note.locked) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_DELETE_LOCKED_ATTEMPT text: STRING_DELETE_LOCKED_ATTEMPT
}); });
return; return;
@@ -539,7 +539,7 @@ class EditorCtrl extends PureCtrl {
title: title, title: title,
permanently: permanently permanently: permanently
}); });
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: text, text: text,
destructive: true, destructive: true,
onConfirm: () => { onConfirm: () => {
@@ -605,7 +605,7 @@ class EditorCtrl extends PureCtrl {
emptyTrash() { emptyTrash() {
const count = this.getTrashCount(); const count = this.getTrashCount();
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: StringEmptyTrash({ count }), text: StringEmptyTrash({ count }),
destructive: true, destructive: true,
onConfirm: () => { onConfirm: () => {

View File

@@ -254,7 +254,7 @@ class FooterCtrl extends PureCtrl {
this.isRefreshing = false; this.isRefreshing = false;
}, 200); }, 200);
if (response && response.error) { if (response && response.error) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_GENERIC_SYNC_ERROR text: STRING_GENERIC_SYNC_ERROR
}); });
} else { } else {
@@ -273,7 +273,7 @@ class FooterCtrl extends PureCtrl {
clickedNewUpdateAnnouncement() { clickedNewUpdateAnnouncement() {
this.newUpdateAvailable = false; this.newUpdateAvailable = false;
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_NEW_UPDATE_READY text: STRING_NEW_UPDATE_READY
}); });
} }

View File

@@ -55,7 +55,7 @@ class LockScreenCtrl extends PureCtrl {
} }
beginDeleteData() { beginDeleteData() {
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: "Are you sure you want to clear all local data?", text: "Are you sure you want to clear all local data?",
destructive: true, destructive: true,
onConfirm: async () => { onConfirm: async () => {

View File

@@ -85,7 +85,7 @@ class RootCtrl extends PureCtrl {
handleChallengeFailures: (responses) => { handleChallengeFailures: (responses) => {
for (const response of responses) { for (const response of responses) {
if (response.challenge === Challenges.LocalPasscode) { if (response.challenge === Challenges.LocalPasscode) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: "Invalid passcode. Please try again.", text: "Invalid passcode. Please try again.",
onClose: () => { onClose: () => {
this.lockScreenPuppet.focusInput(); this.lockScreenPuppet.focusInput();
@@ -188,13 +188,13 @@ class RootCtrl extends PureCtrl {
// if (!lastShownDate || lastShownSeconds > SHOW_INTERVAL) { // if (!lastShownDate || lastShownSeconds > SHOW_INTERVAL) {
// lastShownDate = new Date(); // lastShownDate = new Date();
// setTimeout(() => { // setTimeout(() => {
// this.alertManager.alert({ // this.alertService.alert({
// text: STRING_SESSION_EXPIRED // text: STRING_SESSION_EXPIRED
// }); // });
// }, 500); // }, 500);
// } // }
// } else if (syncEvent === 'sync-exception') { // } else if (syncEvent === 'sync-exception') {
// this.alertManager.alert({ // this.alertService.alert({
// text: StringSyncException(data) // text: StringSyncException(data)
// }); // });
// } // }
@@ -247,7 +247,7 @@ class RootCtrl extends PureCtrl {
window.addEventListener('drop', (event) => { window.addEventListener('drop', (event) => {
if (event.dataTransfer.files.length > 0) { if (event.dataTransfer.files.length > 0) {
event.preventDefault(); event.preventDefault();
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_DEFAULT_FILE_ERROR text: STRING_DEFAULT_FILE_ERROR
}); });
} }

View File

@@ -226,7 +226,7 @@ class TagsPanelCtrl extends PureCtrl {
const matchingTag = this.application.findTag({ title: tag.title }); const matchingTag = this.application.findTag({ title: tag.title });
const alreadyExists = matchingTag && matchingTag !== tag; const alreadyExists = matchingTag && matchingTag !== tag;
if (this.state.newTag === tag && alreadyExists) { if (this.state.newTag === tag && alreadyExists) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: "A tag with this name already exists." text: "A tag with this name already exists."
}); });
/** @todo Should not be accessing internal function */ /** @todo Should not be accessing internal function */
@@ -257,7 +257,7 @@ class TagsPanelCtrl extends PureCtrl {
} }
removeTag(tag) { removeTag(tag) {
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: STRING_DELETE_TAG, text: STRING_DELETE_TAG,
destructive: true, destructive: true,
onConfirm: () => { onConfirm: () => {

View File

@@ -4,14 +4,14 @@ export class Database {
} }
setApplication(application) { setApplication(application) {
this.alertManager = application.alertManager; this.alertService = application.alertService;
} }
displayOfflineAlert() { displayOfflineAlert() {
var message = "There was an issue loading your offline database. This could happen for two reasons:"; var message = "There was an issue loading your offline database. This could happen for two reasons:";
message += "\n\n1. You're in a private window in your browser. We can't save your data without access to the local database. Please use a non-private window."; message += "\n\n1. You're in a private window in your browser. We can't save your data without access to the local database. Please use a non-private window.";
message += "\n\n2. You have two windows of the app open at the same time. Please close any other app instances and reload the page."; message += "\n\n2. You have two windows of the app open at the same time. Please close any other app instances and reload the page.";
this.alertManager.alert({ text: message }); this.alertService.alert({ text: message });
} }
setLocked(locked) { setLocked(locked) {
@@ -28,7 +28,7 @@ export class Database {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request.onerror = (event) => { request.onerror = (event) => {
if (event.target.errorCode) { if (event.target.errorCode) {
this.alertManager.alert({ text: 'Offline database issue: ' + event.target.errorCode }); this.alertService.alert({ text: 'Offline database issue: ' + event.target.errorCode });
} else { } else {
this.displayOfflineAlert(); this.displayOfflineAlert();
} }
@@ -93,7 +93,7 @@ export class Database {
async savePayloads(payloads) { async savePayloads(payloads) {
const showGenericError = (error) => { const showGenericError = (error) => {
this.alertManager.alert({ this.alertService.alert({
text: `Unable to save changes locally due to an unknown system issue. Issue Code: ${error.code} Issue Name: ${error.name}.` text: `Unable to save changes locally due to an unknown system issue. Issue Code: ${error.code} Issue Name: ${error.name}.`
}); });
}; };
@@ -118,7 +118,7 @@ export class Database {
console.error('Offline saving aborted:', event); console.error('Offline saving aborted:', event);
const error = event.target.error; const error = event.target.error;
if (error.name === 'QuotaExceededError') { if (error.name === 'QuotaExceededError') {
this.alertManager.alert({ text: this.alertService.alert({ text:
'Unable to save changes locally because your device is out of space. Please free up some disk space and try again, otherwise, your data may end up in an inconsistent state.' 'Unable to save changes locally because your device is out of space. Please free up some disk space and try again, otherwise, your data may end up in an inconsistent state.'
}); });
} else { } else {
@@ -177,7 +177,7 @@ export class Database {
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.alertService.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

@@ -215,7 +215,7 @@ class AccountMenuCtrl extends PureCtrl {
mfa: null mfa: null
}); });
if (error.message) { if (error.message) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: error.message text: error.message
}); });
} }
@@ -228,7 +228,7 @@ class AccountMenuCtrl extends PureCtrl {
async register() { async register() {
const confirmation = this.state.formData.password_conf; const confirmation = this.state.formData.password_conf;
if (confirmation !== this.state.formData.user_password) { if (confirmation !== this.state.formData.user_password) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_NON_MATCHING_PASSWORDS text: STRING_NON_MATCHING_PASSWORDS
}); });
return; return;
@@ -254,7 +254,7 @@ class AccountMenuCtrl extends PureCtrl {
await this.setFormDataState({ await this.setFormDataState({
authenticating: false authenticating: false
}); });
this.application.alertManager.alert({ this.application.alertService.alert({
text: error.message text: error.message
}); });
} else { } else {
@@ -265,7 +265,7 @@ class AccountMenuCtrl extends PureCtrl {
mergeLocalChanged() { mergeLocalChanged() {
if (!this.state.formData.mergeLocal) { if (!this.state.formData.mergeLocal) {
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: STRING_ACCOUNT_MENU_UNCHECK_MERGE, text: STRING_ACCOUNT_MENU_UNCHECK_MERGE,
destructive: true, destructive: true,
onCancel: () => { onCancel: () => {
@@ -303,7 +303,7 @@ class AccountMenuCtrl extends PureCtrl {
} }
destroyLocalData() { destroyLocalData() {
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: STRING_SIGN_OUT_CONFIRMATION, text: STRING_SIGN_OUT_CONFIRMATION,
destructive: true, destructive: true,
onConfirm: async () => { onConfirm: async () => {
@@ -327,7 +327,7 @@ class AccountMenuCtrl extends PureCtrl {
const data = JSON.parse(e.target.result); const data = JSON.parse(e.target.result);
resolve(data); resolve(data);
} catch (e) { } catch (e) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_INVALID_IMPORT_FILE text: STRING_INVALID_IMPORT_FILE
}); });
} }
@@ -390,11 +390,11 @@ class AccountMenuCtrl extends PureCtrl {
}); });
if (errorCount > 0) { if (errorCount > 0) {
const message = StringImportError({ errorCount: errorCount }); const message = StringImportError({ errorCount: errorCount });
this.application.alertManager.alert({ this.application.alertService.alert({
text: message text: message
}); });
} else { } else {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_IMPORT_SUCCESS text: STRING_IMPORT_SUCCESS
}); });
} }
@@ -471,7 +471,7 @@ class AccountMenuCtrl extends PureCtrl {
submitPasscodeForm() { submitPasscodeForm() {
const passcode = this.state.formData.passcode; const passcode = this.state.formData.passcode;
if (passcode !== this.state.formData.confirmPasscode) { if (passcode !== this.state.formData.confirmPasscode) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: STRING_NON_MATCHING_PASSCODES text: STRING_NON_MATCHING_PASSCODES
}); });
return; return;
@@ -513,7 +513,7 @@ class AccountMenuCtrl extends PureCtrl {
if (!signedIn) { if (!signedIn) {
message += STRING_REMOVE_PASSCODE_OFFLINE_ADDENDUM; message += STRING_REMOVE_PASSCODE_OFFLINE_ADDENDUM;
} }
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: message, text: message,
destructive: true, destructive: true,
onConfirm: () => { onConfirm: () => {

View File

@@ -27,7 +27,7 @@ class ConflictResolutionCtrl {
} }
keepItem1() { keepItem1() {
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: `Are you sure you want to delete the item on the right?`, text: `Are you sure you want to delete the item on the right?`,
destructive: true, destructive: true,
onConfirm: () => { onConfirm: () => {
@@ -39,7 +39,7 @@ class ConflictResolutionCtrl {
} }
keepItem2() { keepItem2() {
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: `Are you sure you want to delete the item on the left?`, text: `Are you sure you want to delete the item on the left?`,
destructive: true, destructive: true,
onConfirm: () => { onConfirm: () => {

View File

@@ -101,20 +101,20 @@ class PasswordWizardCtrl extends PureCtrl {
const currentPassword = this.state.formData.currentPassword; const currentPassword = this.state.formData.currentPassword;
const newPass = this.props.securityUpdate ? currentPassword : this.state.formData.newPassword; const newPass = this.props.securityUpdate ? currentPassword : this.state.formData.newPassword;
if (!currentPassword || currentPassword.length === 0) { if (!currentPassword || currentPassword.length === 0) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: "Please enter your current password." text: "Please enter your current password."
}); });
return false; return false;
} }
if (this.props.changePassword) { if (this.props.changePassword) {
if (!newPass || newPass.length === 0) { if (!newPass || newPass.length === 0) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: "Please enter a new password." text: "Please enter a new password."
}); });
return false; return false;
} }
if (newPass !== this.state.formData.newPasswordConfirmation) { if (newPass !== this.state.formData.newPasswordConfirmation) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: "Your new password does not match its confirmation." text: "Your new password does not match its confirmation."
}); });
this.state.formData.status = null; this.state.formData.status = null;
@@ -122,7 +122,7 @@ class PasswordWizardCtrl extends PureCtrl {
} }
} }
if (!this.application.getUser().email) { if (!this.application.getUser().email) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: "We don't have your email stored. Please log out then log back in to fix this issue." text: "We don't have your email stored. Please log out then log back in to fix this issue."
}); });
this.state.formData.status = null; this.state.formData.status = null;
@@ -134,7 +134,7 @@ class PasswordWizardCtrl extends PureCtrl {
password: this.state.formData.currentPassword password: this.state.formData.currentPassword
}); });
if (!success) { if (!success) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: "The current password you entered is not correct. Please try again." text: "The current password you entered is not correct. Please try again."
}); });
} }
@@ -163,7 +163,7 @@ class PasswordWizardCtrl extends PureCtrl {
processing: success processing: success
}); });
if (!success) { if (!success) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: response.error.message text: response.error.message
? response.error.message ? response.error.message
: "There was an error changing your password. Please try again." : "There was an error changing your password. Please try again."
@@ -187,7 +187,7 @@ class PasswordWizardCtrl extends PureCtrl {
dismiss() { dismiss() {
if (this.state.lockContinue) { if (this.state.lockContinue) {
this.application.alertManager.alert({ this.application.alertService.alert({
text: "Cannot close window until pending tasks are complete." text: "Cannot close window until pending tasks are complete."
}); });
} else { } else {

View File

@@ -99,7 +99,7 @@ class RevisionPreviewModalCtrl {
}; };
if (!asCopy) { if (!asCopy) {
this.application.alertManager.confirm({ this.application.alertService.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

View File

@@ -45,7 +45,7 @@ class SessionHistoryMenuCtrl {
} }
clearItemHistory() { clearItemHistory() {
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: "Are you sure you want to delete the local session history for this note?", text: "Are you sure you want to delete the local session history for this note?",
destructive: true, destructive: true,
onConfirm: () => { onConfirm: () => {
@@ -59,7 +59,7 @@ class SessionHistoryMenuCtrl {
} }
clearAllHistory() { clearAllHistory() {
this.application.alertManager.confirm({ this.application.alertService.confirm({
text: "Are you sure you want to delete the local session history for all notes?", text: "Are you sure you want to delete the local session history for all notes?",
destructive: true, destructive: true,
onConfirm: () => { onConfirm: () => {
@@ -81,7 +81,7 @@ class SessionHistoryMenuCtrl {
}); });
}; };
if (!this.application.historyManager.diskEnabled) { if (!this.application.historyManager.diskEnabled) {
this.application.alertManager.confirm({ this.application.alertService.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
performance, especially as you type. You are advised to disable this feature performance, especially as you type. You are advised to disable this feature
if you experience any lagging.`, if you experience any lagging.`,

View File

@@ -2,7 +2,7 @@
import { SNAlertService } from 'snjs'; import { SNAlertService } from 'snjs';
import { SKAlert } from 'sn-stylekit'; import { SKAlert } from 'sn-stylekit';
export class AlertManager extends SNAlertService { export class AlertService extends SNAlertService {
async alert({ async alert({
title, title,
text, text,

View File

@@ -1,4 +1,4 @@
export { AlertManager } from './alertManager'; export { AlertService } from './alertService';
export { ArchiveManager } from './archiveManager'; export { ArchiveManager } from './archiveManager';
export { DesktopManager } from './desktopManager'; export { DesktopManager } from './desktopManager';
export { GodService } from './godService'; export { GodService } from './godService';

87032
dist/javascripts/app.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2652
dist/stylesheets/app.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
package-lock.json generated
View File

@@ -9797,8 +9797,8 @@
} }
}, },
"snjs": { "snjs": {
"version": "github:standardnotes/snjs#b9d7b7939a8f123798e553ab705916e5251b0981", "version": "github:standardnotes/snjs#ea2f182ba4b53642516714396bbef264f25e373b",
"from": "github:standardnotes/snjs#b9d7b7939a8f123798e553ab705916e5251b0981", "from": "github:standardnotes/snjs#ea2f182ba4b53642516714396bbef264f25e373b",
"dev": true "dev": true
}, },
"sort-keys": { "sort-keys": {

View File

@@ -48,7 +48,7 @@
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"serve-static": "^1.14.1", "serve-static": "^1.14.1",
"sn-stylekit": "2.0.20", "sn-stylekit": "2.0.20",
"snjs": "github:standardnotes/snjs#b9d7b7939a8f123798e553ab705916e5251b0981", "snjs": "github:standardnotes/snjs#ea2f182ba4b53642516714396bbef264f25e373b",
"webpack": "^4.41.5", "webpack": "^4.41.5",
"webpack-cli": "^3.3.10" "webpack-cli": "^3.3.10"
}, },

View File

@@ -1,2 +1,2 @@
(window.webpackJsonpSNCrypto=window.webpackJsonpSNCrypto||[]).push([[0],{123:function(t,c){},124:function(t,c){},166:function(t,c,n){"use strict";n.r(c);var o=n(18);n.d(c,"ready",(function(){return o.ready})),n.d(c,"crypto_pwhash",(function(){return o.crypto_pwhash})),n.d(c,"crypto_pwhash_ALG_DEFAULT",(function(){return o.crypto_pwhash_ALG_DEFAULT})),n.d(c,"crypto_aead_xchacha20poly1305_ietf_encrypt",(function(){return o.crypto_aead_xchacha20poly1305_ietf_encrypt})),n.d(c,"crypto_aead_xchacha20poly1305_ietf_decrypt",(function(){return o.crypto_aead_xchacha20poly1305_ietf_decrypt}))},48:function(t,c){},88:function(t,c){},90:function(t,c){}}]); (window.webpackJsonpSNCrypto=window.webpackJsonpSNCrypto||[]).push([[0],{125:function(t,c){},126:function(t,c){},168:function(t,c,n){"use strict";n.r(c);var o=n(21);n.d(c,"ready",(function(){return o.ready})),n.d(c,"crypto_pwhash",(function(){return o.crypto_pwhash})),n.d(c,"crypto_pwhash_ALG_DEFAULT",(function(){return o.crypto_pwhash_ALG_DEFAULT})),n.d(c,"crypto_aead_xchacha20poly1305_ietf_encrypt",(function(){return o.crypto_aead_xchacha20poly1305_ietf_encrypt})),n.d(c,"crypto_aead_xchacha20poly1305_ietf_decrypt",(function(){return o.crypto_aead_xchacha20poly1305_ietf_decrypt}))},51:function(t,c){},91:function(t,c){},93:function(t,c){}}]);
//# sourceMappingURL=libsodium.bundle.js.map //# sourceMappingURL=libsodium.bundle.js.map

File diff suppressed because one or more lines are too long