mozilla-b2g/gaia — pull request #14043 by evhan55 (2013-11-26 04:49:00+00:00)
Title: Bug 936641 - [Messages][Drafts] Create message drafts upon user interaction

- `drafts.js`
- `add()`
- checked if draft being added is already stored (checking against recipients, content, subject)
- if so, then don't push it or store it
- call `store()` if new, unique draft is being added
- add `subject` field to `Draft`
- `message_manager.js`
- call to save message draft upon visibility change to hidden from new compose window or thread
- `thread_ui.js`
- call to save message draft upon clicking back button from new compose window or thread
- `saveMessageDraft()`
- if there is unsent content in the composer, or recipients in the to field, then save a draft
- assimilates the recipients first, checks for existing `threadID` based on the list of recipients
- `threads.js`
- added `forEach` to be able to check all the thread id's and recipients
- Tests
- `drafts_test.js`
- added subjects to dummy drafts
- added tests for correct storage behavior in `add()`
- `message_manager_test.js`
- tested calls to save draft upon visibility change from new compose window or thread
- `thread_ui_test.js`
- tested calls to save draft upon clicking back button from new compose window or thread
- unit test for `saveMessageDraft()`
- updated mocks