Mailspring/internal_packages/thread-snooze/lib/snooze-store.js
Juan Tejada a5ee197660 feat(snooze): Adds initial design pass and update snooze popover
Summary:
- Add FixedPopover, an absolutely positioned popover component to use for swipe snoozing:
  - This component needs to be finished, as its current behavior is primarily for the snooze plugin
- Updates popover.cjsx to properly render pointer for thesnooze popover for the `down` direction
- Adds new design assets
- Adds date input to snooze popover

Test Plan: - TODO

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2624
2016-02-23 20:03:42 -08:00

43 lines
1.3 KiB
JavaScript

/** @babel */
import _ from 'underscore';
import {Actions, NylasAPI, AccountStore} from 'nylas-exports';
import {moveThreadsToSnooze} from './snooze-category-helpers';
import {PLUGIN_ID, PLUGIN_NAME} from './snooze-constants';
import SnoozeActions from './snooze-actions';
class SnoozeStore {
constructor(pluginId = PLUGIN_ID) {
this.pluginId = pluginId
this.unsubscribe = SnoozeActions.snoozeThreads.listen(this.onSnoozeThreads)
}
onSnoozeThreads = (threads, snoozeDate)=> {
const accounts = AccountStore.accountsForItems(threads)
const promises = accounts.map((acc)=> {
return NylasAPI.authPlugin(this.pluginId, PLUGIN_NAME, acc)
})
Promise.all(promises)
.then(()=> {
return moveThreadsToSnooze(threads)
})
.then((updatedThreadsByAccountId)=> {
_.each(updatedThreadsByAccountId, (update)=> {
const {updatedThreads, snoozeCategoryId, returnCategoryId} = update;
Actions.setMetadata(updatedThreads, this.pluginId, {snoozeDate, snoozeCategoryId, returnCategoryId})
})
})
.catch((error)=> {
NylasEnv.reportError(error);
NylasEnv.showErrorDialog(`Sorry, we were unable to save your snooze settings. ${error.message}`);
});
};
deactivate() {
this.unsubscribe()
}
}
export default SnoozeStore;