From 3e4a3356318a9ae5d037004074441eab76ad1998 Mon Sep 17 00:00:00 2001 From: talksik Date: Fri, 31 Dec 2021 03:06:15 -0800 Subject: [PATCH] handles both ways now pretty smooth for two people but don't know about three --- nirvana-ios/Views/Convos/ConvoViewModel.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nirvana-ios/Views/Convos/ConvoViewModel.swift b/nirvana-ios/Views/Convos/ConvoViewModel.swift index 81aa34b..44da5ed 100644 --- a/nirvana-ios/Views/Convos/ConvoViewModel.swift +++ b/nirvana-ios/Views/Convos/ConvoViewModel.swift @@ -86,12 +86,17 @@ class ConvoViewModel: NSObject, ObservableObject { continue } - // TODO: if convo receiver is me and I'm not in a call or this call already, then join in + // if convo receiver is me and I'm not in a call or this call already, then join in if convo!.receiverUserId == userId && !(self?.isInCall())! && convo!.receiverEndedTimestamp == nil { self?.joinConvo(convo: convo!) } + // if I am in a convo in which the last/loner has left, I need to leave the convo + if convo!.receiverEndedTimestamp != nil && (self?.isInCall())! && convo!.users.contains(userId!) { + self?.leaveConvo() + } + self?.allConvos.append(convo!) }