-
-
Notifications
You must be signed in to change notification settings - Fork 20
Description
We are building a chat app using ngx-ui-scroll
Seems we have an issue with understanding of how to properly do one thing
Let's say we have data source with 50 messages
Now a user sends 2 new messages, so we call adapter.append to show them, all is good
Then we have messages states, so by default the state is sent and a user can receive a delivered state signal per each message.
So once we receive a delivery signal - we update a special field of message in redux, which causes our subscription to get an updated messages array from redux:
this.conversationRepo.getSelectedConversationMessages().subscribe(messages => {
// 50 messages
})
So we got 2 signals about delivered state (for our new messages we sent) and then got our subscription called 2 times as well
And here we have 2 questions:
-
if we want to re-render a single message item to update message.state mark in UI, how we can do it? I see
adapter.reloadwhich should be a proper way, but it does not receive a single item index to reload, but astartIndexinstead which will cause more items to be reloaded -
Is there a way just to connect a redux to ngx-ui-scroll and then it will do all it's job what changed and need to be reloaded and what's not ?
As an alternative idea - my initial idea was to call adapter.reload() all the time we have a redux upgraded (w/o startIndex) and also to have a new method in adapter shouldReload which will then determine should an item be reloaded or not
this.datasource = new Datasource ({
get: (index, count, success) => {
const data = this.getAdpterData(index, count).reverse();
success(data);
},
shouldReload: (index) => {
return true/false;
}
});
Could you please let me know your thoughts re this