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

fix(systemaddon): Limit the number of topsites being rendered. #3081

Merged
merged 1 commit into from
Aug 3, 2017

Conversation

piatra
Copy link
Contributor

@piatra piatra commented Aug 3, 2017

Closes #2945.
Cause of bug seems more of an edge case: if you switch from AS to Tiles you could get different sites presented to you and pin > 12 sites. I managed to get 14 pinned sites on my profile. These show up on PINNED_SITES_UPDATED actions because the reducer does not slice the results.
I moved the slice in the actual component this way we could catch the issue if it happens from other sources as well.
It should not be a problem for people coming over from Tiles because they only had at most 12 tiles.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.407% when pulling c186a0a on piatra:bug-2945-topsite-overflow into 62be2b7 on mozilla:master.

@Mardak
Copy link
Member

Mardak commented Aug 3, 2017

Any reason not to do this from the reducer? I also see there is basically the same .slice-12 logic in TopSitesFeed which would be annoying to make sure they're kept in sync.

@piatra
Copy link
Contributor Author

piatra commented Aug 3, 2017

@Mardak agreed. I initially tried to do this in the reducer and import the 12 constant from TopSitesFeed but that results in a circular dependency. So I decided it made more sense (if I have to duplicate the constant) to do it in the component. Should I create a constants file for this?

@Mardak
Copy link
Member

Mardak commented Aug 3, 2017

@k88hudson any suggestions on this? If we just put the 12 const only in Reducer it would result in more-than-necessary work in TopSitesFeed.refresh and in the passing around of data for TOP_SITES_UPDATED.

Perhaps a step back, the reason why the extra pinned sites appear is that there's a PINNED_SITES_UPDATED that updates the TopSites state. And now taking a closer look at TopSitesFeed._getPinnedWithData, it seems like there could be logic from refresh that should be there too? Maybe instead of PINNED_SITES_UPDATED we just call refresh to dispatch TOP_SITES_UPDATED ?

@k88hudson
Copy link
Contributor

k88hudson commented Aug 3, 2017

The only disadvantage to handling PINNED_SITES_UPDATED with a refresh is that it might cause some lag on slower computers, which is probably something we don't want;

In terms of sharing a constant, why not just define it in Reducers.jsm and import in TopSites?

@Mardak
Copy link
Member

Mardak commented Aug 3, 2017

After some chatting with @rlr on irc. It sounds like refresh should be called infrequently probably to avoid re-querying SQL via NewTabUtils.activityStreamLinks.getTopSites(). And there is existing refresh-once-per-15-minutes logic on NEW_TAB_LOAD. If we are only concerned about the SQL overhead, we can cache it locally, e.g.,

async getFrecent(force) {
  if (force || 15 minutes passed) {
    this._frecent = await NewTabUtils.activityStreamLinks.getTopSites()
  }
  return this._frecent;
}
async getLinksWithDefaults(force) {
  let frecent = await this.getFrecent(force);
}

@Mardak
Copy link
Member

Mardak commented Aug 3, 2017

I suppose frequent refreshes also trigger more broadcasting..

Copy link
Member

@Mardak Mardak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the const from TopSitesFeed to export from Reducers and use that value to slice from both TopSitesFeed and Reducers

@piatra
Copy link
Contributor Author

piatra commented Aug 3, 2017

@Mardak updated.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.407% when pulling 5f5be92 on piatra:bug-2945-topsite-overflow into 62be2b7 on mozilla:master.

@Mardak Mardak merged commit fc9a4ac into mozilla:master Aug 3, 2017
@as-pine-proxy
Copy link
Collaborator

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants