Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 952225 - [Messages][Drafts] Support subject line in message drafts #14867

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/sms/js/compose.js
Expand Up @@ -333,12 +333,18 @@ var Compose = (function() {

fromDraft: function(draft) {
// Clear out the composer
Compose.clear();
this.clear();

// If we don't have a draft, return only having cleared the composer
if (!draft) {
return;
}

if (draft.subject) {
dom.subject.value = draft.subject;
this.toggleSubject();
}

// draft content is an array
draft.content.forEach(function(fragment) {
// If the fragment is an attachment
Expand All @@ -352,6 +358,8 @@ var Compose = (function() {
// Append each fragment in order to the composer
Compose.append(fragment);
}, Compose);

this.focus();
},

getText: function() {
Expand Down
10 changes: 6 additions & 4 deletions apps/sms/js/desktop-only/mobilemessage.js
Expand Up @@ -904,7 +904,7 @@
attachments: ...
}
*/

var now = Date.now();
var sendId = messagesDb.id++;
var request = {
error: null
Expand Down Expand Up @@ -942,7 +942,7 @@
delivery: 'sending',
deliveryInfo: [{receiver: null, deliveryStatus: 'not-applicable'}],
read: true,
subject: '',
subject: params.subject,
smil: params.smil,
attachments: params.attachments,
timestamp: now
Expand Down Expand Up @@ -999,12 +999,12 @@
receiver: null,
delivery: 'received',
id: messagesDb.id++,
timestamp: now,
timestamp: Date.now(),
threadId: thread.id,
type: 'mms',
deliveryInfo: [{deliveryStatus: 'success'}],
read: false,
subject: '',
subject: 'Re: ' + params.subject,
smil: '<smil><body><par><text src="text1"/></par></body></smil>',
attachments: [{
location: 'text1',
Expand All @@ -1016,6 +1016,8 @@
}
};
messagesDb.messages.push(receivedInfo.message);

thread.timestamp = Date.now();
thread.unreadCount++;
trigger('received', receivedInfo);
});
Expand Down
4 changes: 3 additions & 1 deletion apps/sms/js/thread_ui.js
Expand Up @@ -2546,9 +2546,10 @@ var ThreadUI = global.ThreadUI = {
* - preserve, boolean whether or not to preserve draft.
*/
saveDraft: function thui_saveDraft(opts) {
var draft, recipients, content, thread, threadId, type;
var content, draft, recipients, subject, thread, threadId, type;

content = Compose.getContent();
subject = Compose.getSubject();
type = Compose.type;

// TODO Also store subject
Expand All @@ -2565,6 +2566,7 @@ var ThreadUI = global.ThreadUI = {
draft = new Draft({
recipients: recipients,
content: content,
subject: subject,
threadId: threadId,
type: type,
id: draftId
Expand Down
20 changes: 18 additions & 2 deletions apps/sms/test/unit/compose_test.js
Expand Up @@ -113,7 +113,6 @@ suite('compose_test.js', function() {
var text = Compose.getSubject();
assert.equal(text, 'Line 1 Line 2 Line 3');
});

});

suite('Placeholder', function() {
Expand Down Expand Up @@ -357,6 +356,7 @@ suite('compose_test.js', function() {
setup(function() {
Compose.clear();
d1 = new Draft({
subject: '...',
content: ['I am a draft'],
threadId: 1
});
Expand All @@ -367,12 +367,28 @@ suite('compose_test.js', function() {
});
});
teardown(function() {

Compose.clear();
});

test('Draft with text', function() {
Compose.fromDraft(d1);
assert.equal(Compose.getContent(), d1.content.join(''));
});

test('Draft with subject', function() {
this.sinon.spy(Compose, 'toggleSubject');
Compose.fromDraft(d1);
assert.equal(Compose.getSubject(), d1.subject);
assert.isTrue(Compose.isSubjectShowing);
sinon.assert.calledOnce(Compose.toggleSubject);
});

test('Draft without subject', function() {
Compose.fromDraft(d2);
assert.isFalse(Compose.isSubjectShowing);
});

test('Draft with attachment', function() {
Compose.fromDraft(d2);
var txt = Compose.getContent();
Expand Down Expand Up @@ -624,7 +640,7 @@ suite('compose_test.js', function() {
expectType = 'sms';
Compose.clear();
assert.equal(typeChange.called, 2);
});
});
});

suite('changing inputmode', function() {
Expand Down