Merge pull request #2052 from famedly/td/skipExistingChat
feat: allow skipping existing chat when calling startDirectChat
This commit is contained in:
commit
850741df17
|
|
@ -783,10 +783,11 @@ class Client extends MatrixApi {
|
||||||
bool waitForSync = true,
|
bool waitForSync = true,
|
||||||
Map<String, dynamic>? powerLevelContentOverride,
|
Map<String, dynamic>? powerLevelContentOverride,
|
||||||
CreateRoomPreset? preset = CreateRoomPreset.trustedPrivateChat,
|
CreateRoomPreset? preset = CreateRoomPreset.trustedPrivateChat,
|
||||||
|
bool skipExistingChat = false,
|
||||||
}) async {
|
}) async {
|
||||||
// Try to find an existing direct chat
|
// Try to find an existing direct chat
|
||||||
final directChatRoomId = getDirectChatFromUserId(mxid);
|
final directChatRoomId = getDirectChatFromUserId(mxid);
|
||||||
if (directChatRoomId != null) {
|
if (directChatRoomId != null && !skipExistingChat) {
|
||||||
final room = getRoomById(directChatRoomId);
|
final room = getRoomById(directChatRoomId);
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
if (room.membership == Membership.join) {
|
if (room.membership == Membership.join) {
|
||||||
|
|
@ -2266,8 +2267,8 @@ class Client extends MatrixApi {
|
||||||
|
|
||||||
/// Immediately start a sync and wait for completion.
|
/// Immediately start a sync and wait for completion.
|
||||||
/// If there is an active sync already, wait for the active sync instead.
|
/// If there is an active sync already, wait for the active sync instead.
|
||||||
Future<void> oneShotSync() {
|
Future<void> oneShotSync({Duration? timeout}) {
|
||||||
return _sync();
|
return _sync(timeout: timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pass a timeout to set how long the server waits before sending an empty response.
|
/// Pass a timeout to set how long the server waits before sending an empty response.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue