Move saved signatures up in config.json

This commit is contained in:
Ben Gotow 2017-10-05 14:43:13 -07:00
parent beaad725a5
commit 7b714968f9
3 changed files with 12 additions and 14 deletions

View file

@ -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();

View file

@ -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;
}
});

View file

@ -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 => {