blob: 4414e7d659304061d6cb3526bc44fa426940ba66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/. */
const EXPORTED_SYMBOLS = ["ConversationOpener"];
const { Gloda } = ChromeUtils.import("resource:///modules/gloda/Gloda.jsm");
const { GlodaSyntheticView } = ChromeUtils.import(
"resource:///modules/gloda/GlodaSyntheticView.jsm"
);
class ConversationOpener {
static isMessageIndexed(message) {
if (
!Services.prefs.getBoolPref("mailnews.database.global.indexer.enabled")
) {
return false;
}
if (!message || !message.folder) {
return false;
}
return Gloda.isMessageIndexed(message);
}
constructor(window) {
this.window = window;
}
openConversationForMessages(messages) {
if (messages.length < 1) {
return;
}
try {
this._items = [];
this._msgHdr = messages[0];
this._queries = [Gloda.getMessageCollectionForHeaders(messages, this)];
} catch (e) {
console.error(e);
}
}
onItemsAdded(items) {}
onItemsModified(items) {}
onItemsRemoved(items) {}
onQueryCompleted(collection) {
try {
if (!collection.items.length) {
console.error("Couldn't find a collection for msg: " + this._msgHdr);
} else {
let message = collection.items[0];
let tabmail = this.window.top.document.getElementById("tabmail");
if (!tabmail) {
tabmail = Services.wm
.getMostRecentWindow("mail:3pane")
.document.getElementById("tabmail");
}
tabmail.openTab("mail3PaneTab", {
folderPaneVisible: false,
syntheticView: new GlodaSyntheticView({
conversation: message.conversation,
message,
}),
title: message.conversation.subject,
background: false,
});
}
} catch (e) {
console.error(e);
}
}
}
|