@@ -329,7 +329,7 @@ class RustMatrixRoom(
329
329
}
330
330
}
331
331
332
- override suspend fun updateRoomNotificationSettings (): Result <Unit > = withContext(coroutineDispatchers.io ) {
332
+ override suspend fun updateRoomNotificationSettings (): Result <Unit > = withContext(roomDispatcher ) {
333
333
val currentState = _roomNotificationSettingsStateFlow .value
334
334
val currentRoomNotificationSettings = currentState.roomNotificationSettings()
335
335
_roomNotificationSettingsStateFlow .value = MatrixRoomNotificationSettingsState .Pending (prevRoomNotificationSettings = currentRoomNotificationSettings)
@@ -345,7 +345,7 @@ class RustMatrixRoom(
345
345
}
346
346
}
347
347
348
- override suspend fun userRole (userId : UserId ): Result <RoomMember .Role > = withContext(coroutineDispatchers.io ) {
348
+ override suspend fun userRole (userId : UserId ): Result <RoomMember .Role > = withContext(roomDispatcher ) {
349
349
runCatching {
350
350
RoomMemberMapper .mapRole(innerRoom.suggestedRoleForUser(userId.value))
351
351
}
@@ -429,56 +429,56 @@ class RustMatrixRoom(
429
429
}
430
430
}
431
431
432
- override suspend fun canUserInvite (userId : UserId ): Result <Boolean > {
433
- return runCatching {
432
+ override suspend fun canUserInvite (userId : UserId ): Result <Boolean > = withContext(roomDispatcher) {
433
+ runCatching {
434
434
innerRoom.canUserInvite(userId.value)
435
435
}
436
436
}
437
437
438
- override suspend fun canUserKick (userId : UserId ): Result <Boolean > {
439
- return runCatching {
438
+ override suspend fun canUserKick (userId : UserId ): Result <Boolean > = withContext(roomDispatcher) {
439
+ runCatching {
440
440
innerRoom.canUserKick(userId.value)
441
441
}
442
442
}
443
443
444
- override suspend fun canUserBan (userId : UserId ): Result <Boolean > {
445
- return runCatching {
444
+ override suspend fun canUserBan (userId : UserId ): Result <Boolean > = withContext(roomDispatcher) {
445
+ runCatching {
446
446
innerRoom.canUserBan(userId.value)
447
447
}
448
448
}
449
449
450
- override suspend fun canUserRedactOwn (userId : UserId ): Result <Boolean > {
451
- return runCatching {
450
+ override suspend fun canUserRedactOwn (userId : UserId ): Result <Boolean > = withContext(roomDispatcher) {
451
+ runCatching {
452
452
innerRoom.canUserRedactOwn(userId.value)
453
453
}
454
454
}
455
455
456
- override suspend fun canUserRedactOther (userId : UserId ): Result <Boolean > {
457
- return runCatching {
456
+ override suspend fun canUserRedactOther (userId : UserId ): Result <Boolean > = withContext(roomDispatcher) {
457
+ runCatching {
458
458
innerRoom.canUserRedactOther(userId.value)
459
459
}
460
460
}
461
461
462
- override suspend fun canUserSendState (userId : UserId , type : StateEventType ): Result <Boolean > {
463
- return runCatching {
462
+ override suspend fun canUserSendState (userId : UserId , type : StateEventType ): Result <Boolean > = withContext(roomDispatcher) {
463
+ runCatching {
464
464
innerRoom.canUserSendState(userId.value, type.map())
465
465
}
466
466
}
467
467
468
- override suspend fun canUserSendMessage (userId : UserId , type : MessageEventType ): Result <Boolean > {
469
- return runCatching {
468
+ override suspend fun canUserSendMessage (userId : UserId , type : MessageEventType ): Result <Boolean > = withContext(roomDispatcher) {
469
+ runCatching {
470
470
innerRoom.canUserSendMessage(userId.value, type.map())
471
471
}
472
472
}
473
473
474
- override suspend fun canUserTriggerRoomNotification (userId : UserId ): Result <Boolean > {
475
- return runCatching {
474
+ override suspend fun canUserTriggerRoomNotification (userId : UserId ): Result <Boolean > = withContext(roomDispatcher) {
475
+ runCatching {
476
476
innerRoom.canUserTriggerRoomNotification(userId.value)
477
477
}
478
478
}
479
479
480
- override suspend fun canUserPinUnpin (userId : UserId ): Result <Boolean > {
481
- return runCatching {
480
+ override suspend fun canUserPinUnpin (userId : UserId ): Result <Boolean > = withContext(roomDispatcher) {
481
+ runCatching {
482
482
innerRoom.canUserPinUnpin(userId.value)
483
483
}
484
484
}
@@ -676,41 +676,53 @@ class RustMatrixRoom(
676
676
return liveTimeline.sendVoiceMessage(file, audioInfo, waveform, progressCallback)
677
677
}
678
678
679
- override suspend fun typingNotice (isTyping : Boolean ) = runCatching {
680
- innerRoom.typingNotice(isTyping)
679
+ override suspend fun typingNotice (isTyping : Boolean ) = withContext(roomDispatcher) {
680
+ runCatching {
681
+ innerRoom.typingNotice(isTyping)
682
+ }
681
683
}
682
684
683
685
override suspend fun generateWidgetWebViewUrl (
684
686
widgetSettings : MatrixWidgetSettings ,
685
687
clientId : String ,
686
688
languageTag : String? ,
687
689
theme : String? ,
688
- ) = runCatching {
689
- widgetSettings.generateWidgetWebViewUrl(innerRoom, clientId, languageTag, theme)
690
+ ) = withContext(roomDispatcher) {
691
+ runCatching {
692
+ widgetSettings.generateWidgetWebViewUrl(innerRoom, clientId, languageTag, theme)
693
+ }
690
694
}
691
695
692
- override fun getWidgetDriver (widgetSettings : MatrixWidgetSettings ): Result <MatrixWidgetDriver > = runCatching {
693
- RustWidgetDriver (
694
- widgetSettings = widgetSettings,
695
- room = innerRoom,
696
- widgetCapabilitiesProvider = object : WidgetCapabilitiesProvider {
697
- override fun acquireCapabilities (capabilities : WidgetCapabilities ): WidgetCapabilities {
698
- return getElementCallRequiredPermissions(sessionId.value, deviceId.value)
699
- }
700
- },
701
- )
696
+ override fun getWidgetDriver (widgetSettings : MatrixWidgetSettings ): Result <MatrixWidgetDriver > {
697
+ return runCatching {
698
+ RustWidgetDriver (
699
+ widgetSettings = widgetSettings,
700
+ room = innerRoom,
701
+ widgetCapabilitiesProvider = object : WidgetCapabilitiesProvider {
702
+ override fun acquireCapabilities (capabilities : WidgetCapabilities ): WidgetCapabilities {
703
+ return getElementCallRequiredPermissions(sessionId.value, deviceId.value)
704
+ }
705
+ },
706
+ )
707
+ }
702
708
}
703
709
704
- override suspend fun getPermalink (): Result <String > = runCatching {
705
- innerRoom.matrixToPermalink()
710
+ override suspend fun getPermalink (): Result <String > = withContext(roomDispatcher) {
711
+ runCatching {
712
+ innerRoom.matrixToPermalink()
713
+ }
706
714
}
707
715
708
- override suspend fun getPermalinkFor (eventId : EventId ): Result <String > = runCatching {
709
- innerRoom.matrixToEventPermalink(eventId.value)
716
+ override suspend fun getPermalinkFor (eventId : EventId ): Result <String > = withContext(roomDispatcher) {
717
+ runCatching {
718
+ innerRoom.matrixToEventPermalink(eventId.value)
719
+ }
710
720
}
711
721
712
- override suspend fun sendCallNotificationIfNeeded (): Result <Unit > = runCatching {
713
- innerRoom.sendCallNotificationIfNeeded()
722
+ override suspend fun sendCallNotificationIfNeeded (): Result <Unit > = withContext(roomDispatcher) {
723
+ runCatching {
724
+ innerRoom.sendCallNotificationIfNeeded()
725
+ }
714
726
}
715
727
716
728
override suspend fun setSendQueueEnabled (enabled : Boolean ) {
@@ -722,35 +734,45 @@ class RustMatrixRoom(
722
734
}
723
735
}
724
736
725
- override suspend fun saveComposerDraft (composerDraft : ComposerDraft ): Result <Unit > = runCatching {
726
- Timber .d(" saveComposerDraft: $composerDraft into $roomId " )
727
- innerRoom.saveComposerDraft(composerDraft.into())
737
+ override suspend fun saveComposerDraft (composerDraft : ComposerDraft ): Result <Unit > = withContext(roomDispatcher) {
738
+ runCatching {
739
+ Timber .d(" saveComposerDraft: $composerDraft into $roomId " )
740
+ innerRoom.saveComposerDraft(composerDraft.into())
741
+ }
728
742
}
729
743
730
- override suspend fun loadComposerDraft (): Result <ComposerDraft ?> = runCatching {
731
- Timber .d(" loadComposerDraft for $roomId " )
732
- innerRoom.loadComposerDraft()?.into()
744
+ override suspend fun loadComposerDraft (): Result <ComposerDraft ?> = withContext(roomDispatcher) {
745
+ runCatching {
746
+ Timber .d(" loadComposerDraft for $roomId " )
747
+ innerRoom.loadComposerDraft()?.into()
748
+ }
733
749
}
734
750
735
- override suspend fun clearComposerDraft (): Result <Unit > = runCatching {
736
- Timber .d(" clearComposerDraft for $roomId " )
737
- innerRoom.clearComposerDraft()
751
+ override suspend fun clearComposerDraft (): Result <Unit > = withContext(roomDispatcher) {
752
+ runCatching {
753
+ Timber .d(" clearComposerDraft for $roomId " )
754
+ innerRoom.clearComposerDraft()
755
+ }
738
756
}
739
757
740
- override suspend fun ignoreDeviceTrustAndResend (devices : Map <UserId , List <DeviceId >>, sendHandle : SendHandle ) = runCatching {
741
- innerRoom.ignoreDeviceTrustAndResend(
742
- devices = devices.entries.associate { entry ->
743
- entry.key.value to entry.value.map { it.value }
744
- },
745
- sendHandle = (sendHandle as RustSendHandle ).inner,
746
- )
758
+ override suspend fun ignoreDeviceTrustAndResend (devices : Map <UserId , List <DeviceId >>, sendHandle : SendHandle ) = withContext(roomDispatcher) {
759
+ runCatching {
760
+ innerRoom.ignoreDeviceTrustAndResend(
761
+ devices = devices.entries.associate { entry ->
762
+ entry.key.value to entry.value.map { it.value }
763
+ },
764
+ sendHandle = (sendHandle as RustSendHandle ).inner,
765
+ )
766
+ }
747
767
}
748
768
749
- override suspend fun withdrawVerificationAndResend (userIds : List <UserId >, sendHandle : SendHandle ) = runCatching {
750
- innerRoom.withdrawVerificationAndResend(
751
- userIds = userIds.map { it.value },
752
- sendHandle = (sendHandle as RustSendHandle ).inner,
753
- )
769
+ override suspend fun withdrawVerificationAndResend (userIds : List <UserId >, sendHandle : SendHandle ) = withContext(roomDispatcher) {
770
+ runCatching {
771
+ innerRoom.withdrawVerificationAndResend(
772
+ userIds = userIds.map { it.value },
773
+ sendHandle = (sendHandle as RustSendHandle ).inner,
774
+ )
775
+ }
754
776
}
755
777
756
778
private fun createTimeline (
0 commit comments