From 4314c88d5c60a49c48a5b76c6ee3b5aab7d92ca1 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Wed, 9 Sep 2026 15:19:10 -0400 Subject: [PATCH] fallback to empty profile if fetch fails --- gomuks | 2 +- lib/controllers/client.dart | 10 ++++++++-- lib/models/profile_response.dart | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gomuks b/gomuks index 9444dd2..0e06c7b 160000 --- a/gomuks +++ b/gomuks @@ -1 +1 @@ -Subproject commit 9444dd293664c300c6e710bb6cddcd9c6cab365d +Subproject commit 0e06c7b74f96d3e29a8101893ca1921d13a90573 diff --git a/lib/controllers/client.dart b/lib/controllers/client.dart index b7d1eb4..af44d2f 100644 --- a/lib/controllers/client.dart +++ b/lib/controllers/client.dart @@ -2,6 +2,7 @@ import "dart:ffi"; import "dart:io"; import "dart:isolate"; import "dart:math"; + import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:ffi/ffi.dart"; import "package:flutter/foundation.dart"; @@ -261,8 +262,13 @@ class ClientController extends AsyncNotifier { Future paginate(PaginateRequest request) async => .fromJson(await _sendCommand("paginate", request.toJson())); - Future getProfile(String userId) async => - .fromJson(await _sendCommand("get_profile", {"user_id": userId})); + Future getProfile(String userId) async { + try { + return .fromJson(await _sendCommand("get_profile", {"user_id": userId})); + } catch (_) { + return ProfileResponse(profile: .new(id: userId)); + } + } Future reportEvent(ReportRequest request) => _sendCommand("report_event", request.toJson()); diff --git a/lib/models/profile_response.dart b/lib/models/profile_response.dart index 8984bcf..fcaaf2e 100644 --- a/lib/models/profile_response.dart +++ b/lib/models/profile_response.dart @@ -9,7 +9,7 @@ part "profile_response.g.dart"; @JsonSerializable() class const ProfileResponse({ @JsonKey(fromJson: Profile.fromJson) required final Profile profile, - required final Bio? bio, + final Bio? bio, }) with _$ProfileResponse { Map toJson() => _$ProfileResponseToJson(this);