diff --git a/commet/lib/client/matrix/matrix_client.dart b/commet/lib/client/matrix/matrix_client.dart index 7960638a..05609350 100644 --- a/commet/lib/client/matrix/matrix_client.dart +++ b/commet/lib/client/matrix/matrix_client.dart @@ -204,8 +204,8 @@ class MatrixClient extends Client { startSyncLoop: !isBackgroundService, onMigration: () => Log.w("Matrix Database is migrating")); }); - self = - MatrixProfile(_matrixClient, await _matrixClient.fetchOwnProfile()); + + await _updateOwnProfile(); if (!isBackgroundService) { firstSync = _matrixClient.oneShotSync(); @@ -299,11 +299,7 @@ class MatrixClient extends Client { } void _postLoginSuccess() async { - if (_matrixClient.userID != null) { - self = - MatrixProfile(_matrixClient, await _matrixClient.fetchOwnProfile()); - } - + await _updateOwnProfile(); for (var component in getAllComponents()!) { if (component is NeedsPostLoginInit) { (component as NeedsPostLoginInit).postLoginInit(); @@ -311,6 +307,30 @@ class MatrixClient extends Client { } } + Future _updateOwnProfile() async { + final id = _matrixClient.userID; + if (id != null) { + var data = await _matrixClient.database!.getUserProfile(id); + if (data != null) { + self = MatrixProfile( + _matrixClient, + matrix.Profile( + userId: id, + displayName: data.displayname, + avatarUrl: data.avatarUrl, + )); + + // Update own profile, but lets not wait for it before continuing + _matrixClient.getProfileFromUserId(id).then((profile) { + self = MatrixProfile(_matrixClient, profile); + }); + } else { + self = MatrixProfile(_matrixClient, + await _matrixClient.getProfileFromUserId(_matrixClient.userID!)); + } + } + } + void _updateRoomslist() { var joinedRooms = _matrixClient.rooms .where((element) => !element.isSpace && element.membership.isJoin); diff --git a/commet/pubspec.lock b/commet/pubspec.lock index 20c30fd4..9c2e673b 100644 --- a/commet/pubspec.lock +++ b/commet/pubspec.lock @@ -911,16 +911,16 @@ packages: description: path: "." ref: main - resolved-ref: a4e6e73f79138d2044e618697ae43ab81ec2b9c7 + resolved-ref: "9c7c17582080811d4ba88b65977da1a0b7f46350" url: "https://github.com/commetchat/matrix-dart-sdk.git" source: git - version: "0.30.0" + version: "0.32.0" matrix_dart_sdk_drift_db: dependency: "direct main" description: path: "." - ref: update-matrix-sdk - resolved-ref: "0d17db077ca2ce4fb39946779031d97d8a1c7a80" + ref: HEAD + resolved-ref: c2234b7c22847b31cc3bc196bac9759365198f67 url: "https://github.com/commetchat/matrix-dart-sdk-drift-db.git" source: git version: "0.0.1" diff --git a/commet/pubspec.yaml b/commet/pubspec.yaml index 0e30715d..7f7d1933 100644 --- a/commet/pubspec.yaml +++ b/commet/pubspec.yaml @@ -28,10 +28,6 @@ dependencies: intl_translation: ^0.20.0 intl_utils: any just_the_tooltip: ^0.0.12 - matrix: - git: - url: https://github.com/commetchat/matrix-dart-sdk.git - ref: main media_kit: ^1.1.7 media_kit_libs_video: ^1.0.1 media_kit_video: ^1.1.8 @@ -73,10 +69,13 @@ dependencies: ref: fix tiamat: path: ../tiamat/ + matrix: + git: + url: https://github.com/commetchat/matrix-dart-sdk.git + ref: main matrix_dart_sdk_drift_db: git: url: https://github.com/commetchat/matrix-dart-sdk-drift-db.git - ref: update-matrix-sdk encrypted_url_preview: git: https://github.com/commetchat/encrypted_url_preview.git signal_sticker_api: @@ -102,6 +101,12 @@ dependencies: dependency_overrides: # Force dependency overrides for all (direct or transitive) dependencies + + matrix: + git: + url: https://github.com/commetchat/matrix-dart-sdk.git + ref: main + media_kit: git: url: https://github.com/Airyzz/media-kit.git