feat(systemaddon): #2512 Port pocket code to system-addon #2881
Conversation
|
|
||
| if (topics) { | ||
| this.dispatchUpdateEvent(this.topicsLastUpdated, | ||
| {"type": at.SECTION_ROWS_UPDATE, "data": {"id": SECTION_ID, "topics": topics}}); |
AdamHillier
Jul 18, 2017
Contributor
This currently won't work as I didn't anticipate anything other than rows being updated with this event but on reflection it's better if it can handle the general case of any data being updated. The fix would be a one-line change in the reducer (line 194).
-- return Object.assign({}, section, {initialized: true, rows: action.data.rows});
++ return Object.assign({}, section, action.data, {initialized: section.rows || action.data.rows});
We can consider renaming the event to SECTION_UPDATEas well but that is less important. Could also put off this fix until we wire all the parts together.
This currently won't work as I didn't anticipate anything other than rows being updated with this event but on reflection it's better if it can handle the general case of any data being updated. The fix would be a one-line change in the reducer (line 194).
-- return Object.assign({}, section, {initialized: true, rows: action.data.rows});
++ return Object.assign({}, section, action.data, {initialized: section.rows || action.data.rows});
We can consider renaming the event to SECTION_UPDATEas well but that is less important. Could also put off this fix until we wire all the parts together.
|
Just a few comments, mostly looks great |
| @@ -192,7 +192,7 @@ function Sections(prevState = INITIAL_STATE.Sections, action) { | |||
| case at.SECTION_ROWS_UPDATE: | |||
| return prevState.map(section => { | |||
| if (section && section.id === action.data.id) { | |||
| return Object.assign({}, section, {initialized: true, rows: action.data.rows}); | |||
| return Object.assign({}, section, action.data, {initialized: section.rows || action.data.rows}); | |||
k88hudson
Jul 18, 2017
Member
I would argue a better pattern would be simply using rows in the UI to determine whether to show the empty state or not and to do away with initialized altogether, if that's what this property means;
Generally initialized is useful as a way to differentiate between an initial state from the reducer and a natural empty state (i.e. no items were returned)
I would argue a better pattern would be simply using rows in the UI to determine whether to show the empty state or not and to do away with initialized altogether, if that's what this property means;
Generally initialized is useful as a way to differentiate between an initial state from the reducer and a natural empty state (i.e. no items were returned)
csadilek
Jul 18, 2017
Author
Collaborator
done, we removed initialized, as we won't be using it going forward.
done, we removed initialized, as we won't be using it going forward.
| "api_key_pref": "extensions.pocket.oAuthConsumerKey", | ||
| "provider_name": "Pocket", | ||
| "provider_icon": "pocket.svg" | ||
| }` |
k88hudson
Jul 18, 2017
Member
👍
|
|
||
| async fetchStories() { | ||
| if (this.stories_endpoint) { | ||
| const stories = await fetch(this.stories_endpoint) |
k88hudson
Jul 18, 2017
Member
Ideally this should use async/await here instead of chaining promises, but I'd be ok with a clean-up ticket being filed if you think it would take too long
Ideally this should use async/await here instead of chaining promises, but I'd be ok with a clean-up ticket being filed if you think it would take too long
csadilek
Jul 18, 2017
Author
Collaborator
OK, we'll refactor this in a follow-up, once everything is working.
OK, we'll refactor this in a follow-up, once everything is working.
|
|
||
| _normalizeUrl(url) { | ||
| if (url) { | ||
| return url.replace(/\(/g, "%28").replace(/\)/g, "%29"); |
k88hudson
Jul 18, 2017
Member
remind me what this is again?
remind me what this is again?
csadilek
Jul 18, 2017
Author
Collaborator
added the comment that explains this back in.
added the comment that explains this back in.
|
@k88hudson thanks, updates, based on comments. |
This ports all non-ui code i.e. the feed logic, as discussed, including tests. Section events are based on DummySectionFeed.
@k88hudson Can you take a look, please.