forked from Nexus/nexus
bump gomuks, fix profile issues caused by this
This commit is contained in:
parent
1621e917c0
commit
ae5b6e2b40
8 changed files with 50 additions and 30 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
[submodule "gomuks"]
|
[submodule "gomuks"]
|
||||||
path = gomuks
|
path = gomuks
|
||||||
url = https://github.com/gomuks/gomuks
|
url = https://github.com/gomuks/gomuks
|
||||||
branch = timedoutuk/versions-rpc
|
branch = main
|
||||||
|
|
|
||||||
2
gomuks
2
gomuks
|
|
@ -1 +1 @@
|
||||||
Subproject commit d382c664a04f3f202b86f859d1868fd4654a39e8
|
Subproject commit 2d566a2b585e2dba882714f7ca741a52afb36237
|
||||||
|
|
@ -24,7 +24,7 @@ import "package:nexus/models/requests/get_event.dart";
|
||||||
import "package:nexus/models/requests/get_related_events.dart";
|
import "package:nexus/models/requests/get_related_events.dart";
|
||||||
import "package:nexus/models/requests/get_room_state.dart";
|
import "package:nexus/models/requests/get_room_state.dart";
|
||||||
import "package:nexus/models/requests/join_room.dart";
|
import "package:nexus/models/requests/join_room.dart";
|
||||||
import "package:nexus/models/profile.dart";
|
import "package:nexus/models/profile_response.dart";
|
||||||
import "package:nexus/models/requests/oauth/exchange_token.dart";
|
import "package:nexus/models/requests/oauth/exchange_token.dart";
|
||||||
import "package:nexus/models/requests/oauth/get_auth_url.dart";
|
import "package:nexus/models/requests/oauth/get_auth_url.dart";
|
||||||
import "package:nexus/models/requests/oauth/register_client.dart";
|
import "package:nexus/models/requests/oauth/register_client.dart";
|
||||||
|
|
@ -259,10 +259,8 @@ class ClientController extends AsyncNotifier<int> {
|
||||||
Future<Paginate> paginate(PaginateRequest request) async =>
|
Future<Paginate> paginate(PaginateRequest request) async =>
|
||||||
.fromJson(await _sendCommand("paginate", request.toJson()));
|
.fromJson(await _sendCommand("paginate", request.toJson()));
|
||||||
|
|
||||||
Future<Profile> getProfile(String userId) async {
|
Future<ProfileResponse> getProfile(String userId) async =>
|
||||||
final json = await _sendCommand("get_profile", {"user_id": userId});
|
.fromJson(await _sendCommand("get_profile", {"user_id": userId}));
|
||||||
return .fromJsonWithCatch({...json, "id": userId});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> reportEvent(ReportRequest request) =>
|
Future<void> reportEvent(ReportRequest request) =>
|
||||||
_sendCommand("report_event", request.toJson());
|
_sendCommand("report_event", request.toJson());
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:nexus/controllers/client.dart";
|
import "package:nexus/controllers/client.dart";
|
||||||
import "package:nexus/models/profile.dart";
|
import "package:nexus/models/profile_response.dart";
|
||||||
|
|
||||||
class ProfileController extends AsyncNotifier<Profile> {
|
class ProfileController extends AsyncNotifier<ProfileResponse> {
|
||||||
final String userId;
|
final String userId;
|
||||||
ProfileController(this.userId);
|
ProfileController(this.userId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Profile> build() {
|
Future<ProfileResponse> build() {
|
||||||
final client = ref.watch(ClientController.provider.notifier);
|
final client = ref.watch(ClientController.provider.notifier);
|
||||||
return client.getProfile(userId);
|
return client.getProfile(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final provider = AsyncNotifierProvider.family
|
static final provider = AsyncNotifierProvider.family
|
||||||
.autoDispose<ProfileController, Profile, String>(ProfileController.new);
|
.autoDispose<ProfileController, ProfileResponse, String>(
|
||||||
|
ProfileController.new,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,15 @@ class UserController extends AsyncNotifier<MembershipContent> {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
final profile = await ref.watch(
|
final profileResponse = await ref.watch(
|
||||||
ProfileController.provider(config.userId).future,
|
ProfileController.provider(config.userId).future,
|
||||||
);
|
);
|
||||||
|
|
||||||
return .new(
|
return .new(
|
||||||
status: .leave,
|
status: .leave,
|
||||||
avatarUrl: profile.avatarUrl,
|
avatarUrl: profileResponse.profile.avatarUrl,
|
||||||
displayName: profile.displayName ?? config.userId.localpart,
|
displayName:
|
||||||
|
profileResponse.profile.displayName ?? config.userId.localpart,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
import "package:freezed_annotation/freezed_annotation.dart";
|
||||||
import "package:nexus/models/content/content.dart";
|
import "package:nexus/models/content/content.dart";
|
||||||
import "package:nexus/models/epoch_date_time_converter.dart";
|
import "package:nexus/models/epoch_date_time_converter.dart";
|
||||||
import "package:nexus/models/profile.dart";
|
import "package:nexus/models/profile_response.dart";
|
||||||
part "event.freezed.dart";
|
part "event.freezed.dart";
|
||||||
part "event.g.dart";
|
part "event.g.dart";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,37 @@
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
import "package:freezed_annotation/freezed_annotation.dart";
|
||||||
import "package:nexus/models/content/membership.dart";
|
import "package:nexus/models/content/membership.dart";
|
||||||
part "profile.freezed.dart";
|
part "profile_response.freezed.dart";
|
||||||
part "profile.g.dart";
|
part "profile_response.g.dart";
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class ProfileResponse with _$ProfileResponse {
|
||||||
|
const factory ProfileResponse({
|
||||||
|
@JsonKey(fromJson: Profile.fromJson) required Profile profile,
|
||||||
|
required Bio? bio,
|
||||||
|
}) = _ProfileResponse;
|
||||||
|
|
||||||
|
factory ProfileResponse.fromJson(Map<String, Object?> json) =>
|
||||||
|
_$ProfileResponseFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class Bio with _$Bio {
|
||||||
|
const factory Bio({required String html, String? editSource}) = _Bio;
|
||||||
|
|
||||||
|
factory Bio.fromJson(Map<String, Object?> json) => _$BioFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
abstract class Profile with _$Profile {
|
abstract class Profile with _$Profile {
|
||||||
static Object? readPronouns(Map<dynamic, dynamic> map, _) =>
|
static Object? readPronouns(Map<dynamic, dynamic> map, String key) =>
|
||||||
map["m.pronouns"] ?? map["io.fsky.nyx.pronouns"];
|
map[key] ?? map["io.fsky.nyx.pronouns"];
|
||||||
|
|
||||||
static Object? readTimezone(Map<dynamic, dynamic> map, _) =>
|
static Object? readTimezone(Map<dynamic, dynamic> map, String key) =>
|
||||||
map["m.tz"] ?? map["us.cloke.msc4175.tz"];
|
map[key] ?? map["us.cloke.msc4175.tz"];
|
||||||
|
|
||||||
const factory Profile({
|
const factory Profile({
|
||||||
required String id,
|
String? id,
|
||||||
String? parseError,
|
String? parseError,
|
||||||
Uri? avatarUrl,
|
Uri? avatarUrl,
|
||||||
|
|
||||||
|
|
@ -26,7 +44,7 @@ abstract class Profile with _$Profile {
|
||||||
@JsonKey(readValue: Profile.readTimezone, name: "m.tz") String? timezone,
|
@JsonKey(readValue: Profile.readTimezone, name: "m.tz") String? timezone,
|
||||||
|
|
||||||
@Default(IList.empty())
|
@Default(IList.empty())
|
||||||
@JsonKey(readValue: Profile.readPronouns, name: "io.fsky.nyx.pronouns")
|
@JsonKey(readValue: Profile.readPronouns, name: "m.pronouns")
|
||||||
IList<Pronoun> pronouns,
|
IList<Pronoun> pronouns,
|
||||||
}) = _Profile;
|
}) = _Profile;
|
||||||
|
|
||||||
|
|
@ -37,7 +55,7 @@ abstract class Profile with _$Profile {
|
||||||
try {
|
try {
|
||||||
return Profile.fromJson(json);
|
return Profile.fromJson(json);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Profile(id: json["id"], parseError: error.toString());
|
return Profile(parseError: error.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -123,9 +123,10 @@ class UserBottomSheet extends ConsumerWidget {
|
||||||
.watch(ProfileController.provider(userId))
|
.watch(ProfileController.provider(userId))
|
||||||
.betterWhen(
|
.betterWhen(
|
||||||
loading: () => Text(""),
|
loading: () => Text(""),
|
||||||
data: (profile) => Column(
|
data: (profileResponse) => Column(
|
||||||
children: [
|
children: [
|
||||||
if (profile.timezone == null && profile.pronouns.isEmpty)
|
if (profileResponse.profile.timezone == null &&
|
||||||
|
profileResponse.profile.pronouns.isEmpty)
|
||||||
Text(""),
|
Text(""),
|
||||||
Wrap(
|
Wrap(
|
||||||
crossAxisAlignment: .center,
|
crossAxisAlignment: .center,
|
||||||
|
|
@ -133,7 +134,7 @@ class UserBottomSheet extends ConsumerWidget {
|
||||||
spacing: 4,
|
spacing: 4,
|
||||||
runSpacing: 4,
|
runSpacing: 4,
|
||||||
children: [
|
children: [
|
||||||
...profile.pronouns
|
...profileResponse.profile.pronouns
|
||||||
.where(
|
.where(
|
||||||
// TODO: Check system language (l10n)
|
// TODO: Check system language (l10n)
|
||||||
(pronoun) => pronoun.language == "en",
|
(pronoun) => pronoun.language == "en",
|
||||||
|
|
@ -157,8 +158,8 @@ class UserBottomSheet extends ConsumerWidget {
|
||||||
)
|
)
|
||||||
.flattened,
|
.flattened,
|
||||||
|
|
||||||
if (profile.timezone != null) ...[
|
if (profileResponse.profile.timezone != null) ...[
|
||||||
if (profile.pronouns.isNotEmpty)
|
if (profileResponse.profile.pronouns.isNotEmpty)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 16,
|
height: 16,
|
||||||
child: VerticalDivider(
|
child: VerticalDivider(
|
||||||
|
|
@ -168,7 +169,7 @@ class UserBottomSheet extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
profile.timezone!,
|
profileResponse.profile.timezone!,
|
||||||
textAlign: .center,
|
textAlign: .center,
|
||||||
style: textTheme.titleSmall?.copyWith(
|
style: textTheme.titleSmall?.copyWith(
|
||||||
color: theme.colorScheme.onSurfaceVariant,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue