Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update chats.update_last_messages trigger to make sure it is only called for actual last message in case of update #25

Merged
merged 1 commit into from
Dec 26, 2024

Conversation

lazy-geek
Copy link
Contributor

@lazy-geek lazy-geek commented Dec 6, 2024

What does it do?

update the rooms.lastMessages when the actual last message of room is updated and not any other message

Why is it needed?

it can be the case that a message got updated that is not actually the last message, in that case the rooms.lastMessages should not be updated. this pr fixes that

you can see here in example app we update message status

onMessageVisibilityChanged: (message, visible) async {
                if (message.status != types.Status.seen &&
                    message.author.id !=
                        SupabaseChatCore.instance.loggedSupabaseUser!.id) {
                  await SupabaseChatCore.instance.updateMessage(
                    message.copyWith(status: types.Status.seen),
                    widget.room.id,
                  );
                }
              },

but we do it for multiple messages and it is not necessarily that the last message in room will be updated last which can cause rooms.lastMessages to be updated with some other message

How to test it?

you can test it after running the migration and running the example project that the issue i described is fixed by this change

…y called for actual last message in case of update

it can be the case that a message got updated that is not the last message, in that case the `lastMessages` should not be updated
@rickypid rickypid added the enhancement New feature or request label Dec 10, 2024
@rickypid rickypid merged commit 5cfe92c into insideapp-srl:main Dec 26, 2024
2 checks passed
rickypid added a commit that referenced this pull request Dec 26, 2024
## [1.4.3] - 2024-12-26
#### [@rickypid](https://github.com/rickypid)
#### [@lazy-geek](https://github.com/lazy-geek)

ℹ️ ℹ️ **Recommended scheme migration** ℹ️ ℹ️

Improvement documentations.

### Fixed

* Fixed #25 Update chats.update_last_messages trigger to make sure it is only called for actual last message in case of update
* Fixed #27 Error in room or message deletion query, a `limit(1)` was incorrectly applied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants