From 7b714968f9121d7c79284a9b87defb4692a67c1b Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 5 Oct 2017 14:43:13 -0700 Subject: [PATCH] Move saved signatures up in config.json --- .../specs/signature-composer-extension-spec.es6 | 2 +- .../specs/signature-store-spec.jsx | 8 +++----- app/src/flux/stores/signature-store.es6 | 16 ++++++++-------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/internal_packages/composer-signature/specs/signature-composer-extension-spec.es6 b/app/internal_packages/composer-signature/specs/signature-composer-extension-spec.es6 index 6e9136996..f444aef9a 100644 --- a/app/internal_packages/composer-signature/specs/signature-composer-extension-spec.es6 +++ b/app/internal_packages/composer-signature/specs/signature-composer-extension-spec.es6 @@ -16,7 +16,7 @@ describe('SignatureComposerExtension', function signatureComposerExtension() { describe('when a signature is defined', () => { beforeEach(() => { spyOn(AppEnv.config, 'get').andCallFake( - key => (key === 'nylas.signatures' ? TEST_SIGNATURES : null) + key => (key === 'signatures' ? TEST_SIGNATURES : null) ); spyOn(SignatureStore, 'signatureForEmail').andReturn(TEST_SIGNATURE); SignatureStore.activate(); diff --git a/app/internal_packages/composer-signature/specs/signature-store-spec.jsx b/app/internal_packages/composer-signature/specs/signature-store-spec.jsx index bbd98ec6a..e2f939e4a 100644 --- a/app/internal_packages/composer-signature/specs/signature-store-spec.jsx +++ b/app/internal_packages/composer-signature/specs/signature-store-spec.jsx @@ -22,12 +22,10 @@ const DEFAULTS = { describe('SignatureStore', function signatureStore() { beforeEach(() => { - spyOn(AppEnv.config, 'get').andCallFake( - key => (key === 'nylas.signatures' ? SIGNATURES : null) - ); + spyOn(AppEnv.config, 'get').andCallFake(key => (key === 'signatures' ? SIGNATURES : null)); spyOn(SignatureStore, '_saveSignatures').andCallFake(() => { - AppEnv.config.set(`nylas.signatures`, SignatureStore.signatures); + AppEnv.config.set(`signatures`, SignatureStore.signatures); }); spyOn(SignatureStore, 'signatureForEmail').andCallFake(email => SIGNATURES[DEFAULTS[email]]); spyOn(SignatureStore, 'selectedSignature').andCallFake(() => SIGNATURES['1']); @@ -46,7 +44,7 @@ describe('SignatureStore', function signatureStore() { describe('removeSignature', () => { beforeEach(() => { spyOn(AppEnv.config, 'set').andCallFake((key, newObject) => { - if (key === 'nylas.signatures') { + if (key === 'signatures') { SIGNATURES = newObject; } }); diff --git a/app/src/flux/stores/signature-store.es6 b/app/src/flux/stores/signature-store.es6 index fdbd22db5..1d2af8223 100644 --- a/app/src/flux/stores/signature-store.es6 +++ b/app/src/flux/stores/signature-store.es6 @@ -12,8 +12,8 @@ class SignatureStore extends MailspringStore { } activate() { - this.signatures = AppEnv.config.get(`nylas.signatures`) || {}; - this.defaultSignatures = AppEnv.config.get(`nylas.defaultSignatures`) || {}; + this.signatures = AppEnv.config.get(`signatures`) || {}; + this.defaultSignatures = AppEnv.config.get(`defaultSignatures`) || {}; this._autoselectSignatureId(); if (!this.unsubscribers) { @@ -25,12 +25,12 @@ class SignatureStore extends MailspringStore { Actions.toggleAccount.listen(this._onToggleAccount), ]; - AppEnv.config.onDidChange(`nylas.signatures`, () => { - this.signatures = AppEnv.config.get(`nylas.signatures`); + AppEnv.config.onDidChange(`signatures`, () => { + this.signatures = AppEnv.config.get(`signatures`); this.trigger(); }); - AppEnv.config.onDidChange(`nylas.defaultSignatures`, () => { - this.defaultSignatures = AppEnv.config.get(`nylas.defaultSignatures`); + AppEnv.config.onDidChange(`defaultSignatures`, () => { + this.defaultSignatures = AppEnv.config.get(`defaultSignatures`); this.trigger(); }); } @@ -63,11 +63,11 @@ class SignatureStore extends MailspringStore { }; _saveSignatures() { - _.debounce(AppEnv.config.set(`nylas.signatures`, this.signatures), 500); + _.debounce(AppEnv.config.set(`signatures`, this.signatures), 500); } _saveDefaultSignatures() { - _.debounce(AppEnv.config.set(`nylas.defaultSignatures`, this.defaultSignatures), 500); + _.debounce(AppEnv.config.set(`defaultSignatures`, this.defaultSignatures), 500); } _onSelectSignature = id => {