Commits:
-
a9c02248
by Henry Wilkes at 2024-04-22T07:22:05+00:00
fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#connection
Bug 42533: Only update the internal loxId *after* the Lox.activeLoxId
has changed. In particular, we want to ensure that the data associated
with the new loxId (invites and event data) is set before we fetch them.
-
4006866f
by Henry Wilkes at 2024-04-22T07:22:05+00:00
fixup! Lox integration
Bug 42533: Add notification for when the activeLoxId changes.
3 changed files:
Changes:
browser/components/torpreferences/content/connectionPane.js
... |
... |
@@ -1317,6 +1317,7 @@ const gLoxStatus = { |
1317
|
1317
|
});
|
1318
|
1318
|
|
1319
|
1319
|
Services.obs.addObserver(this, TorSettingsTopics.SettingsChanged);
|
|
1320
|
+ Services.obs.addObserver(this, LoxTopics.UpdateActiveLoxId);
|
1320
|
1321
|
Services.obs.addObserver(this, LoxTopics.UpdateEvents);
|
1321
|
1322
|
Services.obs.addObserver(this, LoxTopics.UpdateNextUnlock);
|
1322
|
1323
|
Services.obs.addObserver(this, LoxTopics.UpdateRemainingInvites);
|
... |
... |
@@ -1333,6 +1334,7 @@ const gLoxStatus = { |
1333
|
1334
|
*/
|
1334
|
1335
|
uninit() {
|
1335
|
1336
|
Services.obs.removeObserver(this, TorSettingsTopics.SettingsChanged);
|
|
1337
|
+ Services.obs.removeObserver(this, LoxTopics.UpdateActiveLoxId);
|
1336
|
1338
|
Services.obs.removeObserver(this, LoxTopics.UpdateEvents);
|
1337
|
1339
|
Services.obs.removeObserver(this, LoxTopics.UpdateNextUnlock);
|
1338
|
1340
|
Services.obs.removeObserver(this, LoxTopics.UpdateRemainingInvites);
|
... |
... |
@@ -1343,12 +1345,17 @@ const gLoxStatus = { |
1343
|
1345
|
switch (topic) {
|
1344
|
1346
|
case TorSettingsTopics.SettingsChanged:
|
1345
|
1347
|
const { changes } = subject.wrappedJSObject;
|
1346
|
|
- if (
|
1347
|
|
- changes.includes("bridges.source") ||
|
1348
|
|
- changes.includes("bridges.lox_id")
|
1349
|
|
- ) {
|
|
1348
|
+ if (changes.includes("bridges.source")) {
|
1350
|
1349
|
this._updateLoxId();
|
1351
|
1350
|
}
|
|
1351
|
+ // NOTE: We do not call _updateLoxId when "bridges.lox_id" is in the
|
|
1352
|
+ // changes. Instead we wait until LoxTopics.UpdateActiveLoxId to ensure
|
|
1353
|
+ // that the Lox module has responded to the change in ID strictly
|
|
1354
|
+ // *before* we do. In particular, we want to make sure the invites and
|
|
1355
|
+ // event data has been cleared.
|
|
1356
|
+ break;
|
|
1357
|
+ case LoxTopics.UpdateActiveLoxId:
|
|
1358
|
+ this._updateLoxId();
|
1352
|
1359
|
break;
|
1353
|
1360
|
case LoxTopics.UpdateNextUnlock:
|
1354
|
1361
|
this._updateNextUnlock();
|
... |
... |
@@ -1378,9 +1385,7 @@ const gLoxStatus = { |
1378
|
1385
|
*/
|
1379
|
1386
|
async _updateLoxId() {
|
1380
|
1387
|
let loxId =
|
1381
|
|
- TorSettings.bridges.source === TorBridgeSource.Lox
|
1382
|
|
- ? TorSettings.bridges.lox_id
|
1383
|
|
- : "";
|
|
1388
|
+ TorSettings.bridges.source === TorBridgeSource.Lox ? Lox.activeLoxId : "";
|
1384
|
1389
|
if (loxId === this._loxId) {
|
1385
|
1390
|
return;
|
1386
|
1391
|
}
|
browser/components/torpreferences/content/loxInviteDialog.js
... |
... |
@@ -104,6 +104,7 @@ const gLoxInvites = { |
104
|
104
|
// NOTE: TorSettings should already be initialized when this dialog is
|
105
|
105
|
// opened.
|
106
|
106
|
Services.obs.addObserver(this, TorSettingsTopics.SettingsChanged);
|
|
107
|
+ Services.obs.addObserver(this, LoxTopics.UpdateActiveLoxId);
|
107
|
108
|
Services.obs.addObserver(this, LoxTopics.UpdateRemainingInvites);
|
108
|
109
|
Services.obs.addObserver(this, LoxTopics.NewInvite);
|
109
|
110
|
|
... |
... |
@@ -119,6 +120,7 @@ const gLoxInvites = { |
119
|
120
|
*/
|
120
|
121
|
uninit() {
|
121
|
122
|
Services.obs.removeObserver(this, TorSettingsTopics.SettingsChanged);
|
|
123
|
+ Services.obs.removeObserver(this, LoxTopics.UpdateActiveLoxId);
|
122
|
124
|
Services.obs.removeObserver(this, LoxTopics.UpdateRemainingInvites);
|
123
|
125
|
Services.obs.removeObserver(this, LoxTopics.NewInvite);
|
124
|
126
|
},
|
... |
... |
@@ -127,13 +129,13 @@ const gLoxInvites = { |
127
|
129
|
switch (topic) {
|
128
|
130
|
case TorSettingsTopics.SettingsChanged:
|
129
|
131
|
const { changes } = subject.wrappedJSObject;
|
130
|
|
- if (
|
131
|
|
- changes.includes("bridges.source") ||
|
132
|
|
- changes.includes("bridges.lox_id")
|
133
|
|
- ) {
|
|
132
|
+ if (changes.includes("bridges.source")) {
|
134
|
133
|
this._updateLoxId();
|
135
|
134
|
}
|
136
|
135
|
break;
|
|
136
|
+ case LoxTopics.UpdateActiveLoxId:
|
|
137
|
+ this._updateLoxId();
|
|
138
|
+ break;
|
137
|
139
|
case LoxTopics.UpdateRemainingInvites:
|
138
|
140
|
this._updateRemainingInvites();
|
139
|
141
|
break;
|
... |
... |
@@ -155,9 +157,7 @@ const gLoxInvites = { |
155
|
157
|
*/
|
156
|
158
|
_updateLoxId() {
|
157
|
159
|
const loxId =
|
158
|
|
- TorSettings.bridges.source === TorBridgeSource.Lox
|
159
|
|
- ? TorSettings.bridges.lox_id
|
160
|
|
- : "";
|
|
160
|
+ TorSettings.bridges.source === TorBridgeSource.Lox ? Lox.activeLoxId : "";
|
161
|
161
|
if (!loxId || (this._loxId !== null && loxId !== this._loxId)) {
|
162
|
162
|
// No lox id, or it changed. Close this dialog.
|
163
|
163
|
this._dialog.cancelDialog();
|
toolkit/components/lox/Lox.sys.mjs
... |
... |
@@ -55,6 +55,8 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { |
55
|
55
|
});
|
56
|
56
|
|
57
|
57
|
export const LoxTopics = Object.freeze({
|
|
58
|
+ // Whenever the activeLoxId value changes.
|
|
59
|
+ UpdateActiveLoxId: "lox:update-active-lox-id",
|
58
|
60
|
// Whenever the bridges *might* have changed.
|
59
|
61
|
// getBridges only uses #credentials, so this will only fire when it changes.
|
60
|
62
|
UpdateBridges: "lox:update-bridges",
|
... |
... |
@@ -141,6 +143,10 @@ class LoxImpl { |
141
|
143
|
*/
|
142
|
144
|
#activeLoxId = null;
|
143
|
145
|
|
|
146
|
+ get activeLoxId() {
|
|
147
|
+ return this.#activeLoxId;
|
|
148
|
+ }
|
|
149
|
+
|
144
|
150
|
/**
|
145
|
151
|
* Update the active lox id.
|
146
|
152
|
*/
|
... |
... |
@@ -164,6 +170,8 @@ class LoxImpl { |
164
|
170
|
this.#store();
|
165
|
171
|
}
|
166
|
172
|
this.#activeLoxId = loxId;
|
|
173
|
+
|
|
174
|
+ Services.obs.notifyObservers(null, LoxTopics.UpdateActiveLoxId);
|
167
|
175
|
}
|
168
|
176
|
|
169
|
177
|
observe(subject, topic, data) {
|
|