@@ -159,12 +159,12 @@ export default class BouncerProvider {
159
159
160
160
// Remove any networks we have locally but no longer exist on the BNC
161
161
this . state . networks . forEach ( ( existingNet ) => {
162
- let isNetworkInBncList = ! bncNetworks . find ( ( n ) => (
162
+ let isNetworkInBncList = ! ! bncNetworks . find ( ( n ) => (
163
163
n . networkId === existingNet . connection . bncnetid
164
164
) ) ;
165
165
166
166
if ( existingNet !== network && ! isNetworkInBncList ) {
167
- log ( `Network '${ existingNet . name } ' (${ existingNet . id } ) was not in the BNC, removing locally` ) ;
167
+ log . debug ( `Network '${ existingNet . name } ' (${ existingNet . id } ) was not in the BNC, removing locally` ) ;
168
168
this . state . removeNetwork ( existingNet . id ) ;
169
169
}
170
170
} ) ;
@@ -176,10 +176,17 @@ export default class BouncerProvider {
176
176
async syncBncNetwork ( bncNetwork ) {
177
177
let client = bncNetwork . ircClient ;
178
178
179
- log ( `Syncing network ${ bncNetwork . name } from the BNC` ) ;
179
+ log . debug ( `Syncing network ${ bncNetwork . name } from the BNC` ) ;
180
180
181
181
let buffers = await client . bnc . getBuffers ( bncNetwork . connection . bncnetid ) ;
182
182
buffers . forEach ( ( buffer ) => {
183
+ // The list of buffers also include the network name. Make use of it and make sure our
184
+ // network name is up to date while we can. It may have changed elsewhere
185
+ if ( bncNetwork . name !== buffer . network ) {
186
+ log ( `Detected network name change while syncing buffers. ${ bncNetwork . name } > ${ buffer . network } ` ) ;
187
+ bncNetwork . name = buffer . network ;
188
+ }
189
+
183
190
let newBuffer = this . state . addBuffer ( bncNetwork . id , buffer . name ) ;
184
191
if ( ! newBuffer ) {
185
192
// The BNC might be giving up bad buffer names or something, so just make sure
@@ -252,9 +259,9 @@ export default class BouncerProvider {
252
259
net . connection . server = network . host ;
253
260
net . connection . port = parseInt ( network . port , 10 ) ;
254
261
net . connection . tls = network . tls ;
255
- net . connection . nick = network . nick ;
262
+ net . connection . nick = network . account || network . nick ;
256
263
net . connection . password = network . password || '' ;
257
- net . nick = network . nick ;
264
+ net . nick = network . currentNick || network . nick || '' ;
258
265
net . password = network . account_password ;
259
266
}
260
267
@@ -278,6 +285,7 @@ export default class BouncerProvider {
278
285
host : network . connection . server ,
279
286
port : network . connection . port ,
280
287
tls : network . connection . tls ,
288
+ account : network . connection . nick ,
281
289
account_password : network . password ,
282
290
server_password : network . connection . password ,
283
291
nick : network . connection . nick ,
@@ -291,7 +299,7 @@ export default class BouncerProvider {
291
299
saveState ( ) {
292
300
let controller = this . getController ( ) ;
293
301
if ( ! controller ) {
294
- log ( 'No controller available to save networks' ) ;
302
+ log . debug ( 'No controller available to save networks' ) ;
295
303
return ;
296
304
}
297
305
@@ -327,6 +335,9 @@ export default class BouncerProvider {
327
335
if ( network . password !== snapshot . account_password ) {
328
336
tags . account_password = network . password ;
329
337
}
338
+ if ( network . connection . nick !== snapshot . account ) {
339
+ tags . account = network . connection . nick ;
340
+ }
330
341
if ( network . connection . password !== snapshot . server_password ) {
331
342
tags . password = network . connection . password ;
332
343
}
@@ -340,6 +351,7 @@ export default class BouncerProvider {
340
351
// A newly added network would not have a snapshot name (bncnetid) property set yet.
341
352
// Only save the network if we've entered connection info.
342
353
if ( ! snapshot . bncnetid && tags . host && tags . port && tags . nick ) {
354
+ log ( `Saving new network ${ network . name } to the BNC` ) ;
343
355
// ?? network.connection.bncname = network.name;
344
356
controller . ircClient . bnc . addNetwork (
345
357
network . name ,
@@ -354,6 +366,7 @@ export default class BouncerProvider {
354
366
network . name = networkInfo . network ;
355
367
} ) ;
356
368
} else if ( snapshot . bncnetid && Object . keys ( tags ) . length > 0 ) {
369
+ log ( `Updating network ${ network . name } on the BNC` ) ;
357
370
controller . ircClient . bnc . saveNetwork ( bncnetid , tags ) ;
358
371
}
359
372
} ) ;
@@ -407,7 +420,7 @@ export default class BouncerProvider {
407
420
state . $on ( 'network.connecting' , ( event ) => {
408
421
let controller = this . getController ( ) ;
409
422
if ( ! controller ) {
410
- log ( 'No controller available to save network states' ) ;
423
+ log . debug ( 'No controller available to save network states' ) ;
411
424
return ;
412
425
}
413
426
@@ -455,13 +468,12 @@ export default class BouncerProvider {
455
468
state . $on ( 'network.removed' , ( event ) => {
456
469
let controller = this . getController ( ) ;
457
470
if ( ! controller ) {
458
- log ( 'No controller available to save network states' ) ;
471
+ log . debug ( 'No controller available to save network states' ) ;
459
472
return ;
460
473
}
461
474
462
475
if ( event . network . connection . bncnetid ) {
463
- log ( 'Skipping removal of BNC network while in dev' ) ;
464
- // controller.ircClient.bnc.removeNetwork(event.network.connection.bncnetid);
476
+ controller . ircClient . bnc . removeNetwork ( event . network . connection . bncnetid ) ;
465
477
}
466
478
} ) ;
467
479
@@ -472,7 +484,7 @@ export default class BouncerProvider {
472
484
473
485
let controller = this . getController ( ) ;
474
486
if ( ! controller ) {
475
- log ( 'No controller available to save buffer states' ) ;
487
+ log . debug ( 'No controller available to save buffer states' ) ;
476
488
return ;
477
489
}
478
490
0 commit comments