chat-sdk / chat-sdk-android

Chat SDK Android - Open Source Mobile Messenger

Home Page:https://chatsdk.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there any callback to find out when synchronization (local DB <> Firebase) has been completed?

anonym24 opened this issue · comments

Is there any callback to find out when synchronization (local DB <> Firebase) has been completed?

Because based on such issues #666 is would be really helpful

I haven't found anything on this but check the last comment i made on that issue
it works for now

Did you find any solution? My problem is if the user sends a message and the message was still in the sending/uploading state and the user go to any other activity, the firebase and receiver receive the message but the status of the message on the sender side remains sending/uploading. Any help would be highly appreciated

Did you find any solution? My problem is if the user sends a message and the message was still in the sending/uploading state and the user go to any other activity, the firebase and receiver receive the message but the status of the message on the sender side remains sending/uploading. Any help would be highly appreciated

Using greendao I don't think so but using Database refs it is possible asynchronously
ChatSDK already handles this though
Look into when it changes the state of the message or just general uses of the message state and dig through them

The database is synchronizing whenever new data comes in from Firebase. To find out when that is you can use the event object.

Disposable d = ChatSDK.events().sourceOnMain()
            .filter(NetworkEvent.filterType(EventType.UserPresenceUpdated, EventType.ThreadUserRoleUpdated))
            .subscribe(----lamda here----);

Event types:

public enum EventType {
    ThreadAdded,
    ThreadRemoved,
    ThreadDetailsUpdated,
    ThreadMetaUpdated,
    MessageAdded,
    MessageUpdated,
    MessageRemoved,
    MessageSendStatusUpdated,
    ThreadUsersUpdated,
    ThreadUserRoleUpdated,
    UserMetaUpdated,
    UserPresenceUpdated,
    ContactAdded,
    ContactDeleted,
    ContactsUpdated,
    TypingStateUpdated,
    Logout,
    ThreadRead,
    MessageReadReceiptUpdated,
    NearbyUserAdded,
    NearbyUserMoved,
    NearbyUserRemoved,
    NearbyUsersUpdated,
    Error
}

GreenDao doesn't provide any way to notify us when it's data changes annoyingly. But you can use these notifications.