open-im-ios-demo icon indicating copy to clipboard operation
open-im-ios-demo copied to clipboard

Bug: <If all Subjects are subscribed before onConnectSuccess, they will not be able to obtain the latest status after connecting>

Open birdmichael opened this issue 1 year ago • 3 comments

What happened?

BehaviorSubject 如果在onConnectSuccess之前订阅,不会连接后无法获取最新状态 毕竟用的IMController, 基础所有的状态和通知都用的BehaviorSubject 比如我在tabbar订阅了totalUnreadSubject理论应该直接可以拿到最新的值 现在在需要 1.IMController.shared.getTotalUnreadMsgCount 2.IMController.shared.totalUnreadSubject

What did you expect to happen?

并且在每次重练后也要做这2件事情 建议,totalUnreadSubject 默认获取并推送最新值

How can we reproduce it (as minimally and precisely as possible)?

并且在每次重练后也要做这2件事情 建议,totalUnreadSubject 默认获取并推送最新值

Anything else we need to know?

No response

version

```console $ {name} version # paste output here ```

Cloud provider

OS version

```console # On Linux: $ cat /etc/os-release # paste output here $ uname -a # paste output here # On Windows: C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture # paste output here ```

Install tools

birdmichael avatar Dec 18 '23 03:12 birdmichael

// MARK: - 会话方法

public extension IMController { func getConversation(sessionType: ConversationType = .undefine, sourceId: String = "", conversationID: String = "", onSuccess: @escaping CallBack.ConversationInfoOptionalReturnVoid) { if !conversationID.isEmpty { Self.shared.imManager.getMultipleConversation([conversationID]) { conversations in onSuccess(conversations?.first?.toConversationInfo()) } onFailure: { code, msg in print("创建会话失败:(code), .msg:(msg ?? "")") }

    } else {
        let conversationType = OIMConversationType(rawValue: sessionType.rawValue) ?? OIMConversationType.undefine
        
        Self.shared.imManager.getOneConversation(withSessionType: conversationType, sourceID: sourceId) { (conversation: OIMConversationInfo?) in
            onSuccess(conversation?.toConversationInfo())
        } onFailure: { code, msg in
            print("创建会话失败:\(code), .msg:\(msg ?? "")")
        }
    }
}

怎么还吞失败回调呀

birdmichael avatar Jan 24 '24 08:01 birdmichael

// MARK: - 会话方法

public extension IMController { func getConversation(sessionType: ConversationType = .undefine, sourceId: String = "", conversationID: String = "", onSuccess: @escaping CallBack.ConversationInfoOptionalReturnVoid) { if !conversationID.isEmpty { Self.shared.imManager.getMultipleConversation([conversationID]) { conversations in onSuccess(conversations?.first?.toConversationInfo()) } onFailure: { code, msg in print("创建会话失败:(code), .msg:(msg ?? "")") }

    } else {
        let conversationType = OIMConversationType(rawValue: sessionType.rawValue) ?? OIMConversationType.undefine
        
        Self.shared.imManager.getOneConversation(withSessionType: conversationType, sourceID: sourceId) { (conversation: OIMConversationInfo?) in
            onSuccess(conversation?.toConversationInfo())
        } onFailure: { code, msg in
            print("创建会话失败:\(code), .msg:\(msg ?? "")")
        }
    }
}

怎么还吞失败回调呀

https://github.com/openimsdk/open-im-ios-demo/blame/e67914551140e35a7aa24902b9184b2fd04b4635/OUICore/Classes/Core/IMController.swift#L995

birdmichael avatar Jan 24 '24 08:01 birdmichael

@birdmichael Hi, can you pr the relevant code?

std-s avatar Aug 07 '24 08:08 std-s