mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +08:00
579d4ad71b
Summary: - Fixes #1239 - Adds action in composer view to indicate when draft partcipants have changed. This seemed like the simplest way to listen for this change without adding another extension point - Updates signature plugin to listen to this action and update signature accordingly - Adds test Test Plan: - Unit tests Reviewers: evan, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2614
33 lines
865 B
JavaScript
33 lines
865 B
JavaScript
import {DraftStore, AccountStore, Actions} from 'nylas-exports';
|
|
import SignatureUtils from './signature-utils';
|
|
|
|
|
|
class SignatureStore {
|
|
|
|
constructor() {
|
|
this.unsubscribe = ()=> {};
|
|
}
|
|
|
|
activate() {
|
|
this.unsubscribe = Actions.draftParticipantsChanged.listen(this.onParticipantsChanged);
|
|
}
|
|
|
|
onParticipantsChanged(draftClientId, changes) {
|
|
if (!changes.from) { return; }
|
|
DraftStore.sessionForClientId(draftClientId).then((session)=> {
|
|
const draft = session.draft()
|
|
const {accountId} = AccountStore.accountForEmail(changes.from[0].email);
|
|
const signature = NylasEnv.config.get(`nylas.account-${accountId}.signature`) || "";
|
|
|
|
const body = SignatureUtils.applySignature(draft.body, signature);
|
|
session.changes.add({body})
|
|
});
|
|
}
|
|
|
|
deactivate() {
|
|
this.unsubscribe()
|
|
}
|
|
|
|
}
|
|
|
|
export default SignatureStore;
|