"IN_CONVERSATION" was set when the activity was created and "state" in
the intent extras had the value "resume". However, there is no "state"
extra set by default in Android intents, it should be explicitly set,
but as it is not set anywhere in Talk Android code that would make it
dead code and safe to remove.
Moreover, the connection to the call should be initialized again in any
case rather than resumed when "onCreate" is called, as it is likely that
any previous connection would have been ended if the previous activity
instance was destroyed.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
avoid NPE:
java.lang.NullPointerException
at com.nextcloud.talk.chat.data.network.OfflineFirstChatRepository.getCappedMessagesAmountOfChatBlock(OfflineFirstChatRepository.kt:186)
at com.nextcloud.talk.chat.data.network.OfflineFirstChatRepository.access$getCappedMessagesAmountOfChatBlock(OfflineFirstChatRepository.kt:43)
at com.nextcloud.talk.chat.data.network.OfflineFirstChatRepository$loadInitialMessages$1.invokeSuspend(OfflineFirstChatRepository.kt:162)
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Mistake was, that the conversations from DB and sync could differ due to values.
E.g. when a user changed the status, the conversations from DB and sync would differ. So there were conversations (+related messages&chatBlocks) deleted sometimes.
This caused bugs that when entering a chat, all data was loaded again.
In the previous implementation (before this PR), this error was only visible in the UI when you were offline (in this case, nothing was displayed!).
To fix the bug, only the internalId's are compared.
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
If conversation has a newer message id than DB then an online request is necessary
If conversation has an older message id than DB then an online request is not necessary (this could happen when updating of DB is implemented for push notification, not yet done).
If conversation has the same message id like DB than request can be skipped
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Decrease message limit for retries of message loading
make it possible to add any amount (up to 100) of messages to UI for initial loading.
add logging
only make initial request for chat messages when newest message from DB is not equal the lastReadMessage that is offered by the conversation
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>