mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-07 16:48:02 +08:00
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
import NylasStore from 'nylas-store';
|
|
import { Actions } from 'mailspring-exports';
|
|
|
|
class UndoSendStore extends NylasStore {
|
|
constructor() {
|
|
super();
|
|
this._showUndoSend = false;
|
|
this._sendActionTaskId = null;
|
|
}
|
|
|
|
activate() {
|
|
this._unlisteners = [
|
|
Actions.willPerformSendAction.listen(this._onWillPerformSendAction),
|
|
Actions.didPerformSendAction.listen(this._onDidPerformSendAction),
|
|
Actions.didCancelSendAction.listen(this._onDidCancelSendAction),
|
|
];
|
|
}
|
|
|
|
deactivate() {
|
|
this._unlisteners.forEach(unsub => unsub());
|
|
}
|
|
|
|
shouldShowUndoSend() {
|
|
return this._showUndoSend;
|
|
}
|
|
|
|
sendActionTaskId() {
|
|
return this._sendActionTaskId;
|
|
}
|
|
|
|
_onWillPerformSendAction = ({ taskId }) => {
|
|
this._showUndoSend = true;
|
|
this._sendActionTaskId = taskId;
|
|
this.trigger();
|
|
};
|
|
|
|
_onDidPerformSendAction = () => {
|
|
this._showUndoSend = false;
|
|
this._sendActionTaskId = null;
|
|
this.trigger();
|
|
};
|
|
|
|
_onDidCancelSendAction = () => {
|
|
this._showUndoSend = false;
|
|
this._sendActionTaskId = null;
|
|
this.trigger();
|
|
};
|
|
}
|
|
|
|
export default new UndoSendStore();
|