diff --git a/internal_packages/composer-signature/spec/signature-composer-extension-spec.es6 b/internal_packages/composer-signature/spec/signature-composer-extension-spec.es6 index a529542b4..df10bc224 100644 --- a/internal_packages/composer-signature/spec/signature-composer-extension-spec.es6 +++ b/internal_packages/composer-signature/spec/signature-composer-extension-spec.es6 @@ -15,7 +15,9 @@ describe('SignatureComposerExtension', function signatureComposerExtension() { describe("prepareNewDraft", () => { describe("when a signature is defined", () => { beforeEach(() => { - spyOn(NylasEnv.config, 'get').andCallFake(() => TEST_SIGNATURES); + spyOn(NylasEnv.config, 'get').andCallFake((key) => + (key === 'nylas.signatures' ? TEST_SIGNATURES : null) + ); spyOn(SignatureStore, 'signatureForEmail').andReturn(TEST_SIGNATURE) SignatureStore.activate() }); diff --git a/internal_packages/composer-signature/spec/signature-store-spec.jsx b/internal_packages/composer-signature/spec/signature-store-spec.jsx index d71d9e5bb..06a934a2b 100644 --- a/internal_packages/composer-signature/spec/signature-store-spec.jsx +++ b/internal_packages/composer-signature/spec/signature-store-spec.jsx @@ -22,7 +22,7 @@ const DEFAULTS = { describe('SignatureStore', function signatureStore() { beforeEach(() => { - spyOn(NylasEnv.config, 'get').andCallFake(() => SIGNATURES) + spyOn(NylasEnv.config, 'get').andCallFake((key) => (key === 'nylas.signatures' ? SIGNATURES : null)) spyOn(SignatureStore, '_saveSignatures').andCallFake(() => { NylasEnv.config.set(`nylas.signatures`, SignatureStore.signatures) @@ -44,8 +44,10 @@ describe('SignatureStore', function signatureStore() { describe('removeSignature', () => { beforeEach(() => { - spyOn(NylasEnv.config, 'set').andCallFake((notImportant, newObject) => { - SIGNATURES = newObject + spyOn(NylasEnv.config, 'set').andCallFake((key, newObject) => { + if (key === 'nylas.signatures') { + SIGNATURES = newObject; + } }) }) it('should remove the signature from our list of signatures', () => { diff --git a/src/flux/stores/signature-store.es6 b/src/flux/stores/signature-store.es6 index 88a3c8435..c8865fbeb 100644 --- a/src/flux/stores/signature-store.es6 +++ b/src/flux/stores/signature-store.es6 @@ -24,7 +24,6 @@ class SignatureStore extends NylasStore { this.trigger() }); this.signatures = NylasEnv.config.get(`nylas.signatures`) || {} - this.selectedSignatureId = this._setSelectedSignatureId() this.defaultSignatures = NylasEnv.config.get(`nylas.defaultSignatures`) || {} // backfill the new signatures structure with old signatures from < v0.4.45 @@ -44,6 +43,8 @@ class SignatureStore extends NylasStore { this._saveDefaultSignatures(); } + this.selectedSignatureId = this._setSelectedSignatureId() + this.trigger() }