Secondly, what is happening in the Layout section :
I have 2 collections, 1 collection for user 1 and 1 collection for user 2 (I have created 2 collections because this is was the only to display “unread messages” for the correct user)
As you can see below, it’s working perfectly. The signed-in user is seeing his conversations which where his connected e-mail is email_user1 (the user 2 is also seeing his conversations based on the condition where his email_user2 is recongnized as e-mail of the signed-in user.)
I’m not sure why you have to do this. If you have a user-specific column to determine if a message was read or not, wouldn’t it be able to show that in a single collection?
You can structure this with If-Then-Else columns I think.
I think you’re using the wrong thing. Visibility is applied on the component level, tied to your screen’s data. What you would want is filtering the data.
I just tested and unfortunately, Glide is not able to understand the unread_colmun should be checked for user 2 and not user 1, so on so forth.
So I have to find another way to create the unread function while filtering the data on the same column
For information, before that, I created 2 columns (unread_user1 and unread_user2) so that when user1 sends a message, an action would check the unread_user2, so on and so forth.
I think you could have a single user specific boolean column instead of one for each user. Instead of checking the box to mark it as unread, don’t do anything with it and instead only check the box when the message is read. You should only need one checkbox for any number of users since it will be user specific. If the box is unchecked for a user, then it’s unread.
On top of what Jeff suggested, I would have an extra action when the users click the chat item to set the current date/time to a user-specific date/time column.
Then any messages that are before that date/time value is considered read.
Well, the user that creates the message would set the boolean as true. Since it would be a user specific boolean, it would still be unchecked for the second user. So in the end, the boolean would be set to true whenever a message is created and whenever it’s viewed.
But as @ThinhDinh suggests, you may be better off just tracking dates instead.
On the table side, it’s finally working, but unfortunately, I don’t think I have the ability to check/uncheck the ‘unread’ column for the recipient, only for the sender.
Essentially the recipient would call an action when they view the message, which would check the box. My thought is that unchecked=unread and checked=read. I think you are trying to do it the other way around where check=unread, which is a lot harder to achieve.
If you record the timestamp in each message row when it’s created, then you can retrieve the greatest timestamp and compare it to a global user specific timestamp for the entire conversation. If the date recorded the last time a user viewed the conversation is less than the last message date, then they have unread messages. If the date is greater than or equal to the last message date, then they don’t have any unread messages.
THANKS GUY ! It’s finally working ! I was stuck on this since 10 days lol…
I wasn’t aware that the column if-then-else would follow the user-specific logic. I did something (I don’t know what) but at first, it wasn’t following this logic but now, IT DOES