mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 872147 - Make FeedHandler use async prompts. r=mfinkle
This commit is contained in:
parent
5b37bbda6b
commit
184a6d5e0a
@ -72,34 +72,26 @@ var FeedHandler = {
|
|||||||
// First, let's decide on which feed to subscribe
|
// First, let's decide on which feed to subscribe
|
||||||
let feedIndex = -1;
|
let feedIndex = -1;
|
||||||
if (feeds.length > 1) {
|
if (feeds.length > 1) {
|
||||||
// JSON for Prompt
|
let p = new Prompt({
|
||||||
let feedResult = {
|
window: browser.contentWindow,
|
||||||
type: "Prompt:Show",
|
}).setSingleChoiceItems(feeds.map(function(feed) {
|
||||||
multiple: false,
|
return { label: feed.title || feed.href }
|
||||||
selected: [],
|
})).show((function(data) {
|
||||||
listitems: []
|
feedIndex = data.button;
|
||||||
};
|
|
||||||
|
|
||||||
// Build the list of feeds
|
|
||||||
for (let i = 0; i < feeds.length; i++) {
|
|
||||||
let item = {
|
|
||||||
label: feeds[i].title || feeds[i].href,
|
|
||||||
isGroup: false,
|
|
||||||
inGroup: false,
|
|
||||||
disabled: false,
|
|
||||||
id: i
|
|
||||||
};
|
|
||||||
feedResult.listitems.push(item);
|
|
||||||
}
|
|
||||||
feedIndex = JSON.parse(sendMessageToJava(feedResult)).button;
|
|
||||||
} else {
|
|
||||||
// Only a single feed on the page
|
|
||||||
feedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (feedIndex == -1)
|
if (feedIndex == -1)
|
||||||
return;
|
return;
|
||||||
let feedURL = feeds[feedIndex].href;
|
|
||||||
|
this.loadFeed(feeds[feedIndex], browser);
|
||||||
|
}).bind(this));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loadFeed(feeds[0], browser);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
loadFeed: function fh_loadFeed(aFeed, aBrowser) {
|
||||||
|
let feedURL = aFeed.href;
|
||||||
|
|
||||||
// Next, we decide on which service to send the feed
|
// Next, we decide on which service to send the feed
|
||||||
let handlers = this.getContentHandlers(this.TYPE_MAYBE_FEED);
|
let handlers = this.getContentHandlers(this.TYPE_MAYBE_FEED);
|
||||||
@ -107,34 +99,21 @@ var FeedHandler = {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// JSON for Prompt
|
// JSON for Prompt
|
||||||
let handlerResult = {
|
let p = new Prompt({
|
||||||
type: "Prompt:Show",
|
window: aBrowser.contentWindow
|
||||||
multiple: false,
|
}).setSingleChoiceItems(handlers.map(function(handler) {
|
||||||
selected: [],
|
return { label: handler.name };
|
||||||
listitems: []
|
})).show(function(data) {
|
||||||
};
|
if (data.button == -1)
|
||||||
|
|
||||||
// Build the list of handlers
|
|
||||||
for (let i = 0; i < handlers.length; ++i) {
|
|
||||||
let item = {
|
|
||||||
label: handlers[i].name,
|
|
||||||
isGroup: false,
|
|
||||||
inGroup: false,
|
|
||||||
disabled: false,
|
|
||||||
id: i
|
|
||||||
};
|
|
||||||
handlerResult.listitems.push(item);
|
|
||||||
}
|
|
||||||
let handlerIndex = JSON.parse(sendMessageToJava(handlerResult)).button;
|
|
||||||
if (handlerIndex == -1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Merge the handler URL and the feed URL
|
// Merge the handler URL and the feed URL
|
||||||
let readerURL = handlers[handlerIndex].uri;
|
let readerURL = handlers[data.button].uri;
|
||||||
readerURL = readerURL.replace(/%s/gi, encodeURIComponent(feedURL));
|
readerURL = readerURL.replace(/%s/gi, encodeURIComponent(feedURL));
|
||||||
|
|
||||||
// Open the resultant URL in a new tab
|
// Open the resultant URL in a new tab
|
||||||
BrowserApp.addTab(readerURL, { parentId: BrowserApp.selectedTab.id });
|
BrowserApp.addTab(readerURL, { parentId: BrowserApp.selectedTab.id });
|
||||||
}
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user