delthas: 1 Store bouncer network names locally 3 files changed, 23 insertions(+), 3 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~emersion/goguma-dev/patches/37271/mbox | git am -3Learn more about email & git
--- lib/client_controller.dart | 6 ++++++ lib/database.dart | 13 +++++++++++-- lib/models.dart | 7 ++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/client_controller.dart b/lib/client_controller.dart index 72f3e4c..9e82ed6 100644 --- a/lib/client_controller.dart +++ b/lib/client_controller.dart @@ -764,6 +764,12 @@ class ClientController { return; } + if (childNetwork != null && attrs['name'] != null) { + childNetwork.bouncerName = attrs['name']; + _db.storeNetwork(childNetwork.networkEntry); + return; + } + if (bouncerNetwork != null) { // The bouncer network has been updated bouncerNetwork.setAttrs(attrs); diff --git a/lib/database.dart b/lib/database.dart index b1eeba1..1f192fa 100644 --- a/lib/database.dart +++ b/lib/database.dart @@ -57,6 +57,7 @@ class NetworkEntry { int? id; final int server; String? bouncerId; + String? bouncerName; String? _rawBouncerUri; String? _rawIsupport; String? _rawCaps; @@ -70,6 +71,7 @@ class NetworkEntry { 'id': id, 'server': server, 'bouncer_id': bouncerId, + 'bouncer_name': bouncerName, 'bouncer_uri': _rawBouncerUri, 'isupport': _rawIsupport, 'caps': _rawCaps, @@ -84,6 +86,7 @@ class NetworkEntry { id = m['id'] as int, server = m['server'] as int, bouncerId = m['bouncer_id'] as String?, + bouncerName = m['bouncer_name'] as String?, _rawBouncerUri = m['bouncer_uri'] as String?, _rawIsupport = m['isupport'] as String?, _rawCaps = m['caps'] as String?; @@ -336,6 +339,7 @@ class DB { id INTEGER PRIMARY KEY, server INTEGER NOT NULL, bouncer_id TEXT, + bouncer_name TEXT, bouncer_uri TEXT, isupport TEXT, caps TEXT, @@ -480,12 +484,17 @@ class DB { ); '''); } + if (prevVersion < 14) { + batch.execute(''' + ALTER TABLE Network ADD COLUMN bouncer_name TEXT; + '''); + } await batch.commit(); }, onDowngrade: (_, prevVersion, newVersion) async { throw Exception('Attempted to downgrade database from version $prevVersion to version $newVersion'); }, - version: 13, + version: 14, ); return DB._(db); } @@ -540,7 +549,7 @@ class DB { Future<List<NetworkEntry>> listNetworks() async { var entries = await _db.rawQuery(''' - SELECT id, server, bouncer_id, bouncer_uri, isupport, caps + SELECT id, server, bouncer_id, bouncer_name, bouncer_uri, isupport, caps FROM Network ORDER BY id '''); return entries.map((m) => NetworkEntry.fromMap(m)).toList(); diff --git a/lib/models.dart b/lib/models.dart index 3572b4f..f63dfff 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -75,7 +75,7 @@ class NetworkModel extends ChangeNotifier { String get displayName { // If the user has set a custom bouncer network name, use that - var bouncerNetworkName = bouncerNetwork?.name; + var bouncerNetworkName = networkEntry.bouncerName; var bouncerNetworkHost = bouncerNetwork?.host; if (bouncerNetworkName != null && bouncerNetworkName != bouncerNetworkHost) { return bouncerNetworkName; @@ -104,6 +104,11 @@ class NetworkModel extends ChangeNotifier { notifyListeners(); } + set bouncerName(String? bouncerName) { + networkEntry.bouncerName = bouncerName; + notifyListeners(); + } + set nickname(String nickname) { _nickname = nickname; notifyListeners(); base-commit: 7503ffdc2522b8023cf2b4c4431c344f216b1e58 -- 2.17.1
Pushed with some minor edits, thanks!