Commit 7760bd1a authored by Kiryl Vashyla's avatar Kiryl Vashyla

sync date saving updated, checked on device

parent 9f281645
...@@ -229,10 +229,11 @@ class ChatRoomPresenter @Inject constructor( ...@@ -229,10 +229,11 @@ class ChatRoomPresenter @Inject constructor(
//if success - saving last synced time //if success - saving last synced time
if (messages.isEmpty()) { if (messages.isEmpty()) {
//chat history is empty - just saving current date
messagesRepository.saveLastSyncDate(System.currentTimeMillis()) messagesRepository.saveLastSyncDate(System.currentTimeMillis())
} else { } else {
//TODO sort //assume that BE returns ordered messages, the first message is the latest one
messagesRepository.saveLastSyncDate(messages.last().timestamp) messagesRepository.saveLastSyncDate(messages.first().timestamp)
} }
view.showMessages( view.showMessages(
...@@ -529,8 +530,8 @@ class ChatRoomPresenter @Inject constructor( ...@@ -529,8 +530,8 @@ class ChatRoomPresenter @Inject constructor(
)) ))
messagesRepository.saveAll(messages.result) messagesRepository.saveAll(messages.result)
//if success - saving last synced time //if success - saving last synced time
// TODO sort and peek the latest date //assume that BE returns ordered messages, the first message is the latest one
messagesRepository.saveLastSyncDate(messages.result.last().timestamp) messagesRepository.saveLastSyncDate(messages.result.first().timestamp)
launchUI(strategy) { launchUI(strategy) {
view.showNewMessage(models, true) view.showNewMessage(models, true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment