Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
Merge f372555 into 4af08ab
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamHillier committed Jul 20, 2017
2 parents 4af08ab + f372555 commit e0ba002
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PreferencesPane extends React.Component {
<PreferencesInput className="showTopSites" prefName="showTopSites" value={prefs.showTopSites} onChange={this.handleChange}
titleStringId="settings_pane_topsites_header" descStringId="settings_pane_topsites_body" />

<PreferencesInput className="showTopStories" prefName="feeds.topstories" value={prefs["feeds.topstories"]} onChange={this.handleChange}
<PreferencesInput className="showTopStories" prefName="feeds.section.topstories" value={prefs["feeds.section.topstories"]} onChange={this.handleChange}
titleStringId="settings_pane_pocketstories_header" descStringId="settings_pane_pocketstories_body" />

</div>
Expand Down
16 changes: 5 additions & 11 deletions system-addon/lib/ActivityStream.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ const {SnippetsFeed} = Cu.import("resource://activity-stream/lib/SnippetsFeed.js
const {SystemTickFeed} = Cu.import("resource://activity-stream/lib/SystemTickFeed.jsm", {});
const {TelemetryFeed} = Cu.import("resource://activity-stream/lib/TelemetryFeed.jsm", {});
const {TopSitesFeed} = Cu.import("resource://activity-stream/lib/TopSitesFeed.jsm", {});
const {DummySectionFeed} = Cu.import("resource://activity-stream/lib/DummySectionFeed.jsm", {});
const {TopStoriesFeed} = Cu.import("resource://activity-stream/lib/TopStoriesFeed.jsm", {});

const REASON_ADDON_UNINSTALL = 6;

// Sections, keyed by section id
const SECTIONS = new Map([
["dummy_section", {
feed: DummySectionFeed,
["topstories", {
feed: TopStoriesFeed,
prefTitle: "Fetches content recommendations from a configurable content provider",
showByDefault: false
}]
]);

const SECTION_FEEDS_CONFIG = Array.from(SECTIONS.entries()).map(entry => {
const id = entry[0];
const {feed: Feed, showByDefault: value} = entry[1];
const {feed: Feed, prefTitle, showByDefault: value} = entry[1];
return {
name: `section.${id}`,
factory: () => new Feed(),
title: `${id} section feed`,
title: prefTitle || `${id} section feed`,
value
};
});
Expand Down Expand Up @@ -133,12 +133,6 @@ for (const {name, factory, title, value} of SECTION_FEEDS_CONFIG.concat([
factory: () => new TopSitesFeed(),
title: "Queries places and gets metadata for Top Sites section",
value: true
},
{
name: "topstories",
factory: () => new TopStoriesFeed(),
title: "Fetches content recommendations from a configurable content provider",
value: false
}
])) {
const pref = `feeds.${name}`;
Expand Down
60 changes: 0 additions & 60 deletions system-addon/lib/DummySectionFeed.jsm

This file was deleted.

24 changes: 24 additions & 0 deletions system-addon/lib/SectionFeed.jsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* 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/. */
"use strict";

const {utils: Cu} = Components;

const {actionCreators: ac, actionTypes: at} = Cu.import("resource://activity-stream/common/Actions.jsm", {});

this.SectionFeed = class SectionFeed {
constructor() {
if (new.target === SectionFeed) {
throw new TypeError("SectionFeed must be extended and not instantiated directly.");
}
}
init() {
this.store.dispatch(ac.BroadcastToContent({type: at.SECTION_REGISTER, data: this.options}));
}
uninit() {
this.store.dispatch(ac.BroadcastToContent({type: at.SECTION_DEREGISTER, data: this.options.id}));
}
};

this.EXPORTED_SYMBOLS = ["SectionFeed"];
2 changes: 1 addition & 1 deletion system-addon/lib/TopStoriesFeed.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ this.TopStoriesFeed = class TopStoriesFeed {
this.uninit();
break;
case at.FEED_INIT:
if (action.data === "feeds.topstories") {
if (action.data === "feeds.section.topstories") {
this.init();
}
break;
Expand Down
5 changes: 0 additions & 5 deletions system-addon/test/unit/lib/ActivityStream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe("ActivityStream", () => {
beforeEach(() => {
sandbox = sinon.sandbox.create();
({ActivityStream, SECTIONS} = injector({
"lib/DummySectionFeed.jsm": {DummySectionFeed: Fake},
"lib/LocalizationFeed.jsm": {LocalizationFeed: Fake},
"lib/NewTabInit.jsm": {NewTabInit: Fake},
"lib/PlacesFeed.jsm": {PlacesFeed: Fake},
Expand Down Expand Up @@ -123,10 +122,6 @@ describe("ActivityStream", () => {
const feed = as.feeds.get("feeds.snippets")();
assert.instanceOf(feed, Fake);
});
it("should create a TopStories feed", () => {
const feed = as.feeds.get("feeds.topstories")();
assert.instanceOf(feed, Fake);
});
it("should create a SystemTick feed", () => {
const feed = as.feeds.get("feeds.systemtick")();
assert.instanceOf(feed, Fake);
Expand Down
2 changes: 1 addition & 1 deletion system-addon/test/unit/lib/TopStoriesFeed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("Top Stories Feed", () => {
});
it("should initialize on FEED_INIT", () => {
instance.init = sinon.spy();
instance.onAction({type: at.FEED_INIT, data: "feeds.topstories"});
instance.onAction({type: at.FEED_INIT, data: "feeds.section.topstories"});
assert.calledOnce(instance.init);
});
});
Expand Down

0 comments on commit e0ba002

Please sign in to comment.