Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable news v2 by default for Desktop #15779

Merged
merged 1 commit into from
Nov 8, 2022
Merged

Conversation

petemill
Copy link
Member

@petemill petemill commented Nov 3, 2022

Resolves brave/brave-browser#26494

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@petemill petemill self-assigned this Nov 3, 2022
Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

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

Can we not do this serverside? I know Chromium can do something like this via Finch. Would it be possible to test via that system first, before we make a code change?

@petemill
Copy link
Member Author

petemill commented Nov 7, 2022

Can we not do this serverside? I know Chromium can do something like this via Finch. Would it be possible to test via that system first, before we make a code change?

We could but the issue there is that it only applies to restarts after getting finch updates. So, new users would get the old Brave News feature.

<< " is in channel " << locale_info->locale << "."
<< channel_id << " which is subscribed to.";
return true;
if (channels.contains(channel_id)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@fallaciousreasoning I needed to add this conditional since I was experiencing a crash when I modified the tests to include multiple channels. Somehow that was giving me a CHECK crash to do with. the base::Contains concerning FlatMap. I'm not sure why we haven't been experiencing that crash in actual builds though.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I don't think it should be possible to hit this in production - channels is a set of all the Channels from all the LocaleInfos from all the Publishers. So if we get a channel id from a LocaleInfo it must exist in the set.

Obviously, that assumption isn't necessarily true in tests, as we can make up whatever data/channels we like. Another solution would be to make sure the list of publishers that the controller has include all possible channels.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed, I'm inclined to leave that check in since, in that function specifically, channels doesn't necessarily have to be the full list of all channels. It could just be the channels which have a subscription. And it's comparing IDs from one function parameter with another. Since it causes a crash might be safer to defend against a scenario where we have a new Publisher with a new channel and for some reason we didn't update the in memory channels list.

Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

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

Mostly looks pretty good to me, so I'm adding a +1. Looking at this though, I'm wondering whether it would be better to just convert the methods to static on ChannelsController? I'm not sure what the separate file is buying us, and it makes it a bit less obvious where you need to go to find certain bits of information.

For example, to determine whether a channel is subscribed, I currently have to go through the prefs util. However, to subscribe to a channel, I need to go through the channels controller (though there is a subscribe method on the prefs util). What are your thoughts?

I don't think it's worth blocking on this though.

components/brave_today/browser/pref_utils.h Outdated Show resolved Hide resolved
components/brave_today/browser/channels_controller.h Outdated Show resolved Hide resolved
components/brave_today/browser/pref_utils.cc Outdated Show resolved Hide resolved
components/brave_today/browser/urls_unittest.cc Outdated Show resolved Hide resolved
components/brave_today/common/features.cc Show resolved Hide resolved
@petemill petemill force-pushed the news-desktop-v2-enable branch from 484b162 to d007387 Compare November 8, 2022 07:16
@petemill
Copy link
Member Author

petemill commented Nov 8, 2022

I pushed again, removing prefs_util and associated changes! When I started I was supposing I'd need more access in to the prefs to get the tests appropriate for the V2 flag, but it seems like you've already done good work there @fallaciousreasoning and I only needed to add 1 test-accessible function.

Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

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

lgtm!

<< " is in channel " << locale_info->locale << "."
<< channel_id << " which is subscribed to.";
return true;
if (channels.contains(channel_id)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this?

@petemill petemill merged commit c715ec7 into master Nov 8, 2022
@petemill petemill deleted the news-desktop-v2-enable branch November 8, 2022 20:30
@github-actions github-actions bot added this to the 1.47.x - Nightly milestone Nov 8, 2022
petemill added a commit that referenced this pull request Nov 11, 2022
Enable news v2 by default for Desktop
@kjozwiak
Copy link
Member

Verification was completed on master via #15897 (comment) so we can uplift #15897 into 1.46.x.

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

Successfully merging this pull request may close these issues.

Desktop Brave News should be enabled by default
3 participants