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

[Brave News]: Update to new locale format #15681

Merged
merged 12 commits into from
Nov 1, 2022
Merged

Conversation

fallaciousreasoning
Copy link
Contributor

@fallaciousreasoning fallaciousreasoning commented Oct 27, 2022

Resolves brave/brave-browser#26259

Note: This is backwards compatible with the old locales format. I've filed brave/brave-browser#26307 so we can remove the backwards compatible bit once we update the API.

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:

Brave News V2 should work the same as before

@github-actions github-actions bot added the CI/storybook-url Deploy storybook and provide a unique URL for each build label Oct 27, 2022
Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

Everything looks great and seems to work well - just few pieces of feedback here.

There's a build error in Storybook due to stories/today.tsx which is still providing a string array for the locales field of a Publisher.

! [tsl] ERROR in /Users/jenkins/jenkins/workspace/pr-brave-browser-bn-locale-parsing-macos/src/brave/components/brave_new_tab_ui/stories/today.tsx(59,19)
[2022-10-27T02:03:28.456Z] ERR!       TS2322: Type 'string' is not assignable to type 'LocaleInfo'.

components/brave_new_tab_ui/api/brave_news/news.ts Outdated Show resolved Hide resolved
components/brave_today/browser/channels_controller.cc Outdated Show resolved Hide resolved
components/brave_today/browser/channels_controller.cc Outdated Show resolved Hide resolved
@@ -110,12 +111,17 @@ export const useBraveNews = () => {
export const useChannels = (options: { subscribedOnly: boolean } = { subscribedOnly: false }) => {
const { channels } = useBraveNews()
return useMemo(() => Object.values(channels)
.filter(c => c.subscribed || !options.subscribedOnly), [channels, options.subscribedOnly])
.filter(c => c.subscribedLocales.length || !options.subscribedOnly), [channels, options.subscribedOnly])
Copy link
Member

Choose a reason for hiding this comment

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

Is this going to result in displaying all global channels in the initial screen of the Discover section? If so, I think we need to filter to the "current" locale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this is used by the sidebar to ensure we show channels the user has subscribed to in all locales. Thinking about it though, I think we're already showing all channels in all locales (because the channels system just gets all channels from all publishers).

I think (as the system already works like this) we should fix it in a separate PR, as we can't land Rana's backend changes until this is ready.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've filed this issue:
brave/brave-browser#26385

@fallaciousreasoning
Copy link
Contributor Author

@petemill could you PTAL. I fixed the storybook issues added by this PR but I think something in rewards is also broken on master. I had a quick look at fixing it, but there's some prod code which is breaking the Storybook build, and I wasn't sure how to fix it (on this line, https://github.com/brave/brave-core/blob/master/components/brave_vpn/resources/panel/state/store.ts#L47 observer should be implementing ServiceObserverInterface but doesn't).

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@petemill
Copy link
Member

SonarCloud is only complaining about code duplication in the storybook story. I have again attempted to re-configure SonarCloud to ignore this, but we can't re-run without pushing again and that would interrupt the rest of CI. So if the rest passes then we can force merge.

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@fallaciousreasoning fallaciousreasoning force-pushed the bn-locale-parsing branch 2 times, most recently from 2d5b9bc to 7e28e06 Compare November 1, 2022 00:27
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@fallaciousreasoning fallaciousreasoning merged commit 43ac272 into master Nov 1, 2022
@fallaciousreasoning fallaciousreasoning deleted the bn-locale-parsing branch November 1, 2022 05:43
@github-actions github-actions bot added this to the 1.47.x - Nightly milestone Nov 1, 2022
@petemill
Copy link
Member

petemill commented Nov 1, 2022

@fallaciousreasoning Please uplift to 1.46.x when you get a chance

@stephendonner
Copy link
Contributor

Verified PASSED using

Brave 1.47.36 Chromium: 107.0.5304.91 (Official Build) nightly (x86_64)
Revision 3d5948960d62418160796d5831a4d2d7d6c90fa8-refs/branch-heads/5304@{#1097}
OS macOS Version 11.7.1 (Build 20G918)

Steps:

  1. installed 1.47.36
  2. launched Brave
  3. opened brave://flags
  4. set brave://flags/#brave-news-v2 to Enabled
  5. ran from the commandline: --brave-today-host=brave-today-cdn.bravesoftware.com
  6. opened a new-tab page
  7. clicked on Customize
  8. clicked on Turn on Brave News
  9. typed cnn
  10. examined the results

Confirmed I only saw one CNN source on staging (brave-today-cdn.bravesoftware.com)

Screen Shot 2022-11-01 at 2 36 56 PM

@fallaciousreasoning
Copy link
Contributor Author

Uplift is here #15749

kjozwiak added a commit that referenced this pull request Nov 4, 2022
[Uplift] [Brave News]: Update to new locale format (#15681)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/storybook-url Deploy storybook and provide a unique URL for each build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There are three otherwise identical CNN feed sources
4 participants