strvcom / ios-chat-component

Chat modular library
MIT License
1 stars 1 forks source link

Feature/add transactions #54

Closed cejanen closed 4 years ago

cejanen commented 4 years ago

Resume: After all I realize that we can use transaction only at one useful place - send message. Bc of many limitations (can read data after first CUD operation, cant get last document by query etc) its counter-productive to use for delete method. Also bc of limitation its impossible to load message after its sent in transaction and return in callback. As we discussed I used approach to return just id immediately and data are fully reloaded in listen to callback.

cejanen commented 4 years ago

so... @schwarja 1) done
about next two... we're talking about DB transactions 2) delete message is impossible - main comment - limitations of transactions are that you can read one document (you need its reference) (not make a query) and before any create, update, delete operation... so it wont help us only solution and Im not sure it will work to be using transaction would need two more "get" operations 3) why would you use transaction for last seen message? its just one db operation update?

schwarja commented 4 years ago

@cejanen

  1. 🙌
  2. So how about fetching the second newest message and then starting the transaction where you would delete the message and update the last message?
  3. I described that above: When setting a seen attribute it can happen that locally, you have outdated data about seen messages of other users because other users modify the attribute at about the same time and you overwrite their newly seen id with the old one (experience from Surge). I believe we should use a transaction to read the attribute, update my value and write it.
cejanen commented 4 years ago

@schwarja 2) you need to load last two but else it can work hopefully 3) I missed that somehow, will do it