Skip to content

Commit

Permalink
Show drafts on the conversation list
Browse files Browse the repository at this point in the history
  • Loading branch information
Imperiopolis committed Mar 2, 2020
1 parent 9242870 commit 9be7f6f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
// //
// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // Copyright (c) 2020 Open Whisper Systems. All rights reserved.
// //


import Foundation import Foundation
Expand Down
14 changes: 14 additions & 0 deletions Signal/src/ViewControllers/HomeView/ConversationListCell.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -415,6 +415,20 @@ - (NSAttributedString *)attributedSnippetForThread:(ThreadViewModel *)thread isB
}]]; }]];
} }
NSString *displayableText = thread.lastMessageText; NSString *displayableText = thread.lastMessageText;

if (thread.draftText.length > 0 && !hasUnreadMessages) {
displayableText = thread.draftText;

[snippetText
appendAttributedString:[[NSAttributedString alloc]
initWithString:NSLocalizedString(@"HOME_VIEW_DRAFT_PREFIX",
@"A prefix indicating that a message preview is a draft")
attributes:@{
NSFontAttributeName : self.snippetFont.ows_italic,
NSForegroundColorAttributeName : Theme.secondaryTextAndIconColor,
}]];
}

if (displayableText) { if (displayableText) {
[snippetText appendAttributedString:[[NSAttributedString alloc] [snippetText appendAttributedString:[[NSAttributedString alloc]
initWithString:displayableText initWithString:displayableText
Expand Down
3 changes: 3 additions & 0 deletions Signal/translations/en.lproj/Localizable.strings
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1241,6 +1241,9 @@
/* Placeholder text for search bar which filters conversations. */ /* Placeholder text for search bar which filters conversations. */
"HOME_VIEW_CONVERSATION_SEARCHBAR_PLACEHOLDER" = "Search"; "HOME_VIEW_CONVERSATION_SEARCHBAR_PLACEHOLDER" = "Search";


/* A prefix indicating that a message preview is a draft */
"HOME_VIEW_DRAFT_PREFIX" = "Draft: ";

/* Format string for a label offering to start a new conversation with your contacts, if you have 1 Signal contact. Embeds {{The name of 1 of your Signal contacts}}. */ /* Format string for a label offering to start a new conversation with your contacts, if you have 1 Signal contact. Embeds {{The name of 1 of your Signal contacts}}. */
"HOME_VIEW_FIRST_CONVERSATION_OFFER_1_CONTACT_FORMAT" = "Some of your contacts are already on Signal, including %@."; "HOME_VIEW_FIRST_CONVERSATION_OFFER_1_CONTACT_FORMAT" = "Some of your contacts are already on Signal, including %@.";


Expand Down
3 changes: 3 additions & 0 deletions SignalMessaging/ViewModels/ThreadViewModel.swift
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ThreadViewModel: NSObject {
return !isGroupThread return !isGroupThread
} }


@objc public let draftText: String?
@objc public let lastMessageText: String? @objc public let lastMessageText: String?
@objc public let lastMessageForInbox: TSInteraction? @objc public let lastMessageForInbox: TSInteraction?


Expand Down Expand Up @@ -52,6 +53,8 @@ public class ThreadViewModel: NSObject {
} else { } else {
self.addedToGroupByName = nil self.addedToGroupByName = nil
} }

self.draftText = thread.currentDraft(with: transaction)
} }


@objc @objc
Expand Down

0 comments on commit 9be7f6f

Please sign in to comment.