twilio / twilio-conversations-demo-ios-swift

Twilio Conversations for iOS Demo application in Swift
MIT License
18 stars 19 forks source link

Reactions #10

Closed leenatekani5 closed 1 year ago

leenatekani5 commented 1 year ago

Here there is one functionality where you can add reactions to the messages. But when the app is killed state how we can modify the messages attributes. I don't want to redownload all the messages from twilio that are already there in my local db as it will create an overhead of downloading messages for each conversation and saving in db again. Can you tell me how can I fix this.

Gray-Wind commented 1 year ago

Hello,

You read and store in your local DB some messages metadata, is it including index?

You can use this index to get access to the exact message from Conversation.

Let me know if this helps you solve the issue.

leenatekani5 commented 1 year ago

Once the messages are inserted in db I am not refetching or updating from twilio as it will create lot of overhead on the app downloading thousands of messages again. I have added reaction type of functionality in the app and I am adding reactions on message using Message Attributes. While the user is logged in with twilio he will get update in the following method :-

func conversationsClient(_ client: TwilioConversationsClient, conversation: TCHConversation, message: TCHMessage, updated: TCHMessageUpdate)

But if user is not logged in then how I can notify the user that the particular message is updated.

rusmonster commented 1 year ago

Unfortunately SDK doesn't have functionality like "send me all changes which I missed". We will consider to add such feature in future releases.

At the moment recommended approach is to re-request only messages which actually appear on the screen (while user scrolls UI) using the messageWithIndex method. This way it's not necessary to download all messages on each login.

leenatekani5 commented 1 year ago

@rusmonster last option I have is that I manage the message's updated attributes in the conversation attributes and once the user has fetched all the attributes which have latest changes I reset the conversation attributes for me. Just let me know if this is the feasible solution or not. Following is my conversation attributes that I am maintaining in the app :- I will be saving my updated reactions in the "message_rections" key. { "group_profile": "url", "chat_type": "group,one,task", "description" : "Chat Description", "users": [ { "identity": "sam", "name" : "Full Name", "status": "active,archive,requested,pinned,deleted,left,removed,accepted,exited", "profile": "user profile picure", "isAdmin" : "yes,no", "userstatus":"added", "message_reactions":"id1,id2" }, { "identity": "ana", "name" : "Full Name", "status": "active,archive,requested,pinned,deleted,left,removed,accepted,exited", "profile": "user profile picure", "isAdmin" : "yes,no", "userstatus":"added", "message_reactions":"id1,id2" } ], "chat_status" : "completed", "block": "yes", "block_by": "identity", "lastMessage": "", "lastMessageSid": "", "lastMessageTime": "", "deletedMessages":"abc,abc2" }

rusmonster commented 1 year ago

In this approach with increasing count of users and messages - the attributes size can grow unlimited. At the same time attributes have hard 16Kb size limit.

So I would prefer the "re-request only messages which actually appear on the screen" approach.

leenatekani5 commented 1 year ago

@rusmonster I will think over it how I can reload attributes when messages appears on the screen. Thanks for the help. I am closing this issue.