Bug 1903090 - Don't mark a message with hasUnread or hasNew if only the parent message is unread/new. r=mkmelin
#### How to test - Have a threaded message and expand it. - Mark the parent message as **unread**. - Ensure the "Replies" button in the parent message doesn't show the unread indicator. - Mark the parent message as **read**. - Mark a child message as **unread**. - Ensure the "Replies" button in the parent message shows the unread indicator. - Ensure the parent message doesn't get styled as unread. In cards view is more visually obvious but it also matches the logic for table view. Child unread in table view are represented with an underline style on the parent message. Differential Revision: https://phabricator.services.mozilla.com/D214186 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a92ba18525
Коммит
a561dfc7af
|
@ -16,7 +16,13 @@ const threadTree = about3Pane.threadTree;
|
|||
// testing things that happen when about:message is hidden.
|
||||
const aboutMessage = about3Pane.messageBrowser.contentWindow;
|
||||
const messagePaneBrowser = aboutMessage.getMessagePaneBrowser();
|
||||
let rootFolder, folderA, folderB, trashFolder, sourceMessages, sourceMessageIDs;
|
||||
let rootFolder,
|
||||
folderA,
|
||||
folderB,
|
||||
folderC,
|
||||
trashFolder,
|
||||
sourceMessages,
|
||||
sourceMessageIDs;
|
||||
|
||||
add_setup(async function () {
|
||||
const generator = new MessageGenerator();
|
||||
|
@ -32,6 +38,9 @@ add_setup(async function () {
|
|||
.QueryInterface(Ci.nsIMsgLocalMailFolder);
|
||||
|
||||
folderB = rootFolder.createLocalSubfolder("threadTreeQuirksB");
|
||||
folderC = rootFolder
|
||||
.createLocalSubfolder("threadTreeQuirksC")
|
||||
.QueryInterface(Ci.nsIMsgLocalMailFolder);
|
||||
trashFolder = rootFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Trash);
|
||||
|
||||
// Make some messages, then change their dates to simulate a different order.
|
||||
|
@ -47,6 +56,9 @@ add_setup(async function () {
|
|||
folderA.addMessageBatch(
|
||||
syntheticMessages.map(message => message.toMessageString())
|
||||
);
|
||||
folderC.addMessageBatch(
|
||||
syntheticMessages.map(message => message.toMessageString())
|
||||
);
|
||||
sourceMessages = [...folderA.messages];
|
||||
sourceMessageIDs = sourceMessages.map(m => m.messageId);
|
||||
|
||||
|
@ -603,6 +615,51 @@ add_task(async function testThreadTreeA11yRoles() {
|
|||
);
|
||||
});
|
||||
|
||||
add_task(async function test_read_new_properties() {
|
||||
about3Pane.restoreState({
|
||||
messagePaneVisible: true,
|
||||
folderURI: folderC.URI,
|
||||
});
|
||||
|
||||
// Clicking the twisty to collapse a row should update the message display.
|
||||
goDoCommand("cmd_expandAllThreads");
|
||||
threadTree.selectedIndex = 5;
|
||||
await messageLoaded(10);
|
||||
|
||||
// Ensure that a new message thread that is selected and expanded only
|
||||
// marks its children as new and unread.
|
||||
let row = threadTree.getRowAtIndex(5);
|
||||
Assert.ok(!row.dataset.properties.includes("new"));
|
||||
Assert.stringContains(row.dataset.properties, "hasNew");
|
||||
Assert.ok(!row.dataset.properties.includes("unread"));
|
||||
Assert.stringContains(row.dataset.properties, "hasUnread");
|
||||
|
||||
// Ensure that a new message thread that hasn't been selected marks both root
|
||||
// message and its childre and new and unread.
|
||||
row = threadTree.getRowAtIndex(0);
|
||||
Assert.stringContains(row.dataset.properties, "new");
|
||||
Assert.stringContains(row.dataset.properties, "hasNew");
|
||||
Assert.stringContains(row.dataset.properties, "unread");
|
||||
Assert.stringContains(row.dataset.properties, "hasUnread");
|
||||
|
||||
threadTree.selectedIndex = 4;
|
||||
await messageLoaded(9);
|
||||
threadTree.selectedIndex = 3;
|
||||
await messageLoaded(8);
|
||||
threadTree.selectedIndex = 2;
|
||||
await messageLoaded(7);
|
||||
threadTree.selectedIndex = 1;
|
||||
await messageLoaded(6);
|
||||
|
||||
// Ensure that if all the child messages of a thread have been read, only the
|
||||
// root message is marked as new and unread.
|
||||
row = threadTree.getRowAtIndex(0);
|
||||
Assert.stringContains(row.dataset.properties, "new");
|
||||
Assert.ok(!row.dataset.properties.includes("hasNew"));
|
||||
Assert.stringContains(row.dataset.properties, "unread");
|
||||
Assert.ok(!row.dataset.properties.includes("hasUnread"));
|
||||
});
|
||||
|
||||
async function messageLoaded(index) {
|
||||
await BrowserTestUtils.browserLoaded(messagePaneBrowser);
|
||||
Assert.equal(
|
||||
|
|
|
@ -1161,7 +1161,8 @@ nsMsgDBView::GetRowProperties(int32_t index, nsAString& properties) {
|
|||
uint32_t flags;
|
||||
msgHdr->GetFlags(&flags);
|
||||
|
||||
if (!(flags & nsMsgMessageFlags::Read))
|
||||
bool isRead = flags & nsMsgMessageFlags::Read;
|
||||
if (!isRead)
|
||||
properties.AppendLiteral(" unread");
|
||||
else
|
||||
properties.AppendLiteral(" read");
|
||||
|
@ -1174,7 +1175,8 @@ nsMsgDBView::GetRowProperties(int32_t index, nsAString& properties) {
|
|||
if (flags & nsMsgMessageFlags::Redirected)
|
||||
properties.AppendLiteral(" redirected");
|
||||
|
||||
if (flags & nsMsgMessageFlags::New) properties.AppendLiteral(" new");
|
||||
bool isNew = flags & nsMsgMessageFlags::New;
|
||||
if (isNew) properties.AppendLiteral(" new");
|
||||
|
||||
if (m_flags[index] & nsMsgMessageFlags::Marked)
|
||||
properties.AppendLiteral(" flagged");
|
||||
|
@ -1233,10 +1235,20 @@ nsMsgDBView::GetRowProperties(int32_t index, nsAString& properties) {
|
|||
if (NS_SUCCEEDED(rv) && thread) {
|
||||
uint32_t numUnreadChildren;
|
||||
thread->GetNumUnreadChildren(&numUnreadChildren);
|
||||
// If only one message is unread and is the parent message, don't mark the
|
||||
// child thread with hasUnread.
|
||||
if (numUnreadChildren == 1 && !isRead) {
|
||||
numUnreadChildren--;
|
||||
}
|
||||
if (numUnreadChildren > 0) properties.AppendLiteral(" hasUnread");
|
||||
|
||||
uint32_t numNewChildren;
|
||||
thread->GetNumNewChildren(&numNewChildren);
|
||||
// If only one message is new and is the parent message, don't mark the
|
||||
// child thread with hasNew.
|
||||
if (numNewChildren == 1 && isNew) {
|
||||
numNewChildren--;
|
||||
}
|
||||
if (numNewChildren > 0) properties.AppendLiteral(" hasNew");
|
||||
|
||||
// For threaded display add the ignore/watch properties to the
|
||||
|
@ -1293,7 +1305,8 @@ nsMsgDBView::GetCellProperties(int32_t aRow, nsTreeColumn* col,
|
|||
uint32_t flags;
|
||||
msgHdr->GetFlags(&flags);
|
||||
|
||||
if (!(flags & nsMsgMessageFlags::Read))
|
||||
bool isRead = flags & nsMsgMessageFlags::Read;
|
||||
if (!isRead)
|
||||
properties.AppendLiteral(" unread");
|
||||
else
|
||||
properties.AppendLiteral(" read");
|
||||
|
@ -1408,6 +1421,11 @@ nsMsgDBView::GetCellProperties(int32_t aRow, nsTreeColumn* col,
|
|||
if (NS_SUCCEEDED(rv) && thread) {
|
||||
uint32_t numUnreadChildren;
|
||||
thread->GetNumUnreadChildren(&numUnreadChildren);
|
||||
// If only one message is unread and is the parent message, don't mark the
|
||||
// child thread with hasUnread.
|
||||
if (numUnreadChildren == 1 && !isRead) {
|
||||
numUnreadChildren--;
|
||||
}
|
||||
if (numUnreadChildren > 0) properties.AppendLiteral(" hasUnread");
|
||||
|
||||
// For threaded display add the ignore/watch properties to the
|
||||
|
|
Загрузка…
Ссылка в новой задаче