Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
birdmichael opened this issue Dec 18, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@birdmichael
Copy link

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
Copy link
Author

// 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
Copy link
Author

// 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

@std-s std-s changed the title Bug: <所有Subject 如果在onConnectSuccess之前订阅,不会连接后无法获取最新状态> Bug: <If all Subjects are subscribed before onConnectSuccess, they will not be able to obtain the latest status after connecting> Aug 7, 2024
@std-s
Copy link
Member

std-s commented Aug 7, 2024

@birdmichael Hi, can you pr the relevant code?

@std-s std-s added the help wanted Extra attention is needed label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants