Skip to content
Snippets Groups Projects
Verified Commit bb028644 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

fixup! Bug 40597: Implement TorSettings module

Bug 42384: Use TorSettings's initialization promise to handle race
conditions

We now have a race condition for which the notification about
TorSettings being ready is sent before TorConnect can observe this
topic.
A while ago, we introduced an initialization promise to TorSettings,
therefore we can use it instead of Service.obs and avoid this race
condition.

Also, fixed quicksettings ignored in TorSettings.setSettings.
parent db59cb25
Branches
Tags
1 merge request!902Bug 42384: Fix quickstart not working anymore
......@@ -878,10 +878,11 @@ export const TorConnect = (() => {
console.log(`TorConnect: Observing topic '${addTopic}'`);
};
TorSettings.initializedPromise.then(() => this._settingsInitialized());
// register the Tor topics we always care about
observeTopic(TorTopics.ProcessExited);
observeTopic(TorTopics.LogHasWarnOrErr);
observeTopic(TorSettingsTopics.Ready);
}
},
......@@ -889,29 +890,6 @@ export const TorConnect = (() => {
console.log(`TorConnect: Observed ${topic}`);
switch (topic) {
/* We need to wait until TorSettings have been loaded and applied before we can Quickstart */
case TorSettingsTopics.Ready: {
// tor-browser#41907: This is only a workaround to avoid users being
// bounced back to the initial panel without any explanation.
// Longer term we should disable the clickable elements, or find a UX
// to prevent this from happening (e.g., allow buttons to be clicked,
// but show an intermediate starting state, or a message that tor is
// starting while the butons are disabled, etc...).
if (this.state !== TorConnectState.Initial) {
console.warn(
"TorConnect: Seen the torsettings:ready after the state has already changed, ignoring the notification."
);
break;
}
if (this.shouldQuickStart) {
// Quickstart
this._changeState(TorConnectState.Bootstrapping);
} else {
// Configuring
this._changeState(TorConnectState.Configuring);
}
break;
}
case TorTopics.LogHasWarnOrErr: {
this._logHasWarningOrError = true;
break;
......@@ -941,6 +919,28 @@ export const TorConnect = (() => {
}
},
_settingsInitialized() {
// tor-browser#41907: This is only a workaround to avoid users being
// bounced back to the initial panel without any explanation.
// Longer term we should disable the clickable elements, or find a UX
// to prevent this from happening (e.g., allow buttons to be clicked,
// but show an intermediate starting state, or a message that tor is
// starting while the butons are disabled, etc...).
if (this.state !== TorConnectState.Initial) {
console.warn(
"TorConnect: Seen the torsettings:ready after the state has already changed, ignoring the notification."
);
return;
}
if (this.shouldQuickStart) {
// Quickstart
this._changeState(TorConnectState.Bootstrapping);
} else {
// Configuring
this._changeState(TorConnectState.Configuring);
}
},
/*
Various getters
*/
......
......
......@@ -992,6 +992,10 @@ class TorSettingsImpl {
// Hold off on lots of notifications until all settings are changed.
this.freezeNotifications();
try {
if ("quickstart" in settings) {
this.quickstart.enabled = !!settings.quickstart.enabled;
}
if ("bridges" in settings) {
this.bridges.enabled = !!settings.bridges.enabled;
// Currently, disabling bridges in the UI does not remove the lines,
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment