tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 63f81b669bf99415bc1ef54a592d9036c286c66f
parent 1b08161b6dc3e224ace166ed34e9f2d7e9af0a20
Author: Reem H <42309026+reemhamz@users.noreply.github.com>
Date:   Thu,  2 Oct 2025 03:26:50 +0000

Bug 1991807 - Add 'detect my location' item in weather context menu for weather opt-in. r=home-newtab-reviewers,npypchenko

Differential Revision: https://phabricator.services.mozilla.com/D266946

Diffstat:
Mbrowser/extensions/newtab/content-src/components/Weather/Weather.jsx | 5++---
Mbrowser/extensions/newtab/content-src/lib/link-menu-options.mjs | 6++++++
Mbrowser/extensions/newtab/data/content/activity-stream.bundle.js | 12++++++++----
Mbrowser/extensions/newtab/lib/WeatherFeed.sys.mjs | 4++++
4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/browser/extensions/newtab/content-src/components/Weather/Weather.jsx b/browser/extensions/newtab/content-src/components/Weather/Weather.jsx @@ -227,9 +227,6 @@ export class _Weather extends React.PureComponent { handleAcceptOptIn = () => { batch(() => { - this.props.dispatch(ac.SetPref("weather.optInAccepted", true)); - this.props.dispatch(ac.SetPref("weather.optInDisplayed", false)); - this.props.dispatch( ac.AlsoToMain({ type: at.WEATHER_USER_OPT_IN_LOCATION, @@ -314,6 +311,7 @@ export class _Weather extends React.PureComponent { ...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), + ...(Prefs.values["system.showWeatherOptIn"] ? ["DetectLocation"] : []), ...(Prefs.values["weather.temperatureUnits"] === "f" ? ["ChangeTempUnitCelsius"] : ["ChangeTempUnitFahrenheit"]), @@ -327,6 +325,7 @@ export class _Weather extends React.PureComponent { ...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), + ...(Prefs.values["system.showWeatherOptIn"] ? ["DetectLocation"] : []), "HideWeather", "OpenLearnMoreURL", ]; diff --git a/browser/extensions/newtab/content-src/lib/link-menu-options.mjs b/browser/extensions/newtab/content-src/lib/link-menu-options.mjs @@ -331,6 +331,12 @@ export const LinkMenuOptions = { data: true, }), }), + DetectLocation: () => ({ + id: "newtab-weather-menu-detect-my-location", + action: ac.AlsoToMain({ + type: at.WEATHER_USER_OPT_IN_LOCATION, + }), + }), ChangeWeatherDisplaySimple: () => ({ id: "newtab-weather-menu-change-weather-display-simple", action: ac.OnlyToMain({ diff --git a/browser/extensions/newtab/data/content/activity-stream.bundle.js b/browser/extensions/newtab/data/content/activity-stream.bundle.js @@ -2045,6 +2045,12 @@ const LinkMenuOptions = { data: true, }), }), + DetectLocation: () => ({ + id: "newtab-weather-menu-detect-my-location", + action: actionCreators.AlsoToMain({ + type: actionTypes.WEATHER_USER_OPT_IN_LOCATION, + }), + }), ChangeWeatherDisplaySimple: () => ({ id: "newtab-weather-menu-change-weather-display-simple", action: actionCreators.OnlyToMain({ @@ -11826,8 +11832,6 @@ class _Weather extends (external_React_default()).PureComponent { }; handleAcceptOptIn = () => { (0,external_ReactRedux_namespaceObject.batch)(() => { - this.props.dispatch(actionCreators.SetPref("weather.optInAccepted", true)); - this.props.dispatch(actionCreators.SetPref("weather.optInDisplayed", false)); this.props.dispatch(actionCreators.AlsoToMain({ type: actionTypes.WEATHER_USER_OPT_IN_LOCATION })); @@ -11886,8 +11890,8 @@ class _Weather extends (external_React_default()).PureComponent { const showStaticData = isUserWeatherEnabled && isOptInEnabled && staticDataEnabled; // Note: The temperature units/display options will become secondary menu items - const WEATHER_SOURCE_CONTEXT_MENU_OPTIONS = [...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), ...(Prefs.values["weather.temperatureUnits"] === "f" ? ["ChangeTempUnitCelsius"] : ["ChangeTempUnitFahrenheit"]), ...(Prefs.values["weather.display"] === "simple" ? ["ChangeWeatherDisplayDetailed"] : ["ChangeWeatherDisplaySimple"]), "HideWeather", "OpenLearnMoreURL"]; - const WEATHER_SOURCE_SHORTENED_CONTEXT_MENU_OPTIONS = [...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), "HideWeather", "OpenLearnMoreURL"]; + const WEATHER_SOURCE_CONTEXT_MENU_OPTIONS = [...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), ...(Prefs.values["system.showWeatherOptIn"] ? ["DetectLocation"] : []), ...(Prefs.values["weather.temperatureUnits"] === "f" ? ["ChangeTempUnitCelsius"] : ["ChangeTempUnitFahrenheit"]), ...(Prefs.values["weather.display"] === "simple" ? ["ChangeWeatherDisplayDetailed"] : ["ChangeWeatherDisplaySimple"]), "HideWeather", "OpenLearnMoreURL"]; + const WEATHER_SOURCE_SHORTENED_CONTEXT_MENU_OPTIONS = [...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), ...(Prefs.values["system.showWeatherOptIn"] ? ["DetectLocation"] : []), "HideWeather", "OpenLearnMoreURL"]; const contextMenu = contextOpts => /*#__PURE__*/external_React_default().createElement("div", { className: "weatherButtonContextMenuWrapper" }, /*#__PURE__*/external_React_default().createElement("button", { diff --git a/browser/extensions/newtab/lib/WeatherFeed.sys.mjs b/browser/extensions/newtab/lib/WeatherFeed.sys.mjs @@ -325,10 +325,14 @@ export class WeatherFeed { break; } case at.WEATHER_USER_OPT_IN_LOCATION: { + this.store.dispatch(ac.SetPref("weather.optInAccepted", true)); + this.store.dispatch(ac.SetPref("weather.optInDisplayed", false)); + const detectedLocation = await this.fetchLocationByIP(); if (detectedLocation) { // Build the payload exactly like manual search does + this.store.dispatch( ac.BroadcastToContent({ type: at.WEATHER_LOCATION_DATA_UPDATE,