forked from Nexus/nexus
fallback to empty profile if fetch fails
This commit is contained in:
parent
88cdcf9863
commit
4314c88d5c
3 changed files with 10 additions and 4 deletions
2
gomuks
2
gomuks
|
|
@ -1 +1 @@
|
|||
Subproject commit 9444dd293664c300c6e710bb6cddcd9c6cab365d
|
||||
Subproject commit 0e06c7b74f96d3e29a8101893ca1921d13a90573
|
||||
|
|
@ -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<int> {
|
|||
Future<Paginate> paginate(PaginateRequest request) async =>
|
||||
.fromJson(await _sendCommand("paginate", request.toJson()));
|
||||
|
||||
Future<ProfileResponse> getProfile(String userId) async =>
|
||||
.fromJson(await _sendCommand("get_profile", {"user_id": userId}));
|
||||
Future<ProfileResponse> getProfile(String userId) async {
|
||||
try {
|
||||
return .fromJson(await _sendCommand("get_profile", {"user_id": userId}));
|
||||
} catch (_) {
|
||||
return ProfileResponse(profile: .new(id: userId));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> reportEvent(ReportRequest request) =>
|
||||
_sendCommand("report_event", request.toJson());
|
||||
|
|
|
|||
|
|
@ -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<String, Object?> toJson() => _$ProfileResponseToJson(this);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue