feat: allow skipping existing chat when calling startDirectChat

feat: also allow specifying timeout duration in oneShotSync
This commit is contained in:
td 2025-03-17 15:27:43 +01:00
parent 609ee1d4a7
commit 3a9e65d375
No known key found for this signature in database
GPG Key ID: 62A30523D4D6CE28
1 changed files with 4 additions and 3 deletions

View File

@ -783,10 +783,11 @@ class Client extends MatrixApi {
bool waitForSync = true,
Map<String, dynamic>? powerLevelContentOverride,
CreateRoomPreset? preset = CreateRoomPreset.trustedPrivateChat,
bool skipExistingChat = false,
}) async {
// Try to find an existing direct chat
final directChatRoomId = getDirectChatFromUserId(mxid);
if (directChatRoomId != null) {
if (directChatRoomId != null && !skipExistingChat) {
final room = getRoomById(directChatRoomId);
if (room != null) {
if (room.membership == Membership.join) {
@ -2266,8 +2267,8 @@ class Client extends MatrixApi {
/// Immediately start a sync and wait for completion.
/// If there is an active sync already, wait for the active sync instead.
Future<void> oneShotSync() {
return _sync();
Future<void> oneShotSync({Duration? timeout}) {
return _sync(timeout: timeout);
}
/// Pass a timeout to set how long the server waits before sending an empty response.