it is possible to create a reference point in time using Xano? (chat basic notifications)

Options

Hello,

I have developed a chat application and I am trying to implement a feature where notifications are sent when a message is received by the intended recipient. To achieve this, I have two databases - one contains chatroom IDs and the IDs of the two users involved, while the other contains the messages, including the creation time, user ID, message content, and chatroom ID.

All messages between the two users are displayed in a message datatable in chronological order, based on the creation time. I would like to be able to track the number of messages sent by each user after the last message received from the other user.

My question is whether it is possible to create a reference point in time using Xano and how to filter the messages to identify the last message sent by each user based on the last message received from the other user?

Answers

  • Davy
    Davy Member
    Options

    Hey @Ray Deck any ideas for this one?

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    Not sure I understand it completely, but maybe instead of using time as an indicator to determine number of messages from the last one received (be received do you mean seen by the user?). You can create additional boolean field "seen" or "recevived" with False value and on event of opening the chat you go through those messeges and change this parameter to True to reset the count.

  • Davy
    Davy Member
    Options

    @Pawel Magdanski thank you for your feedback, this is indeed a very interesting approach I didn't think about but which could actually work

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    @Pawel Magdanski 's approach is what most DM/PM systems use - a "read" or "delivered" boolean that you can check against and update as they get loaded in. (The methodology gets weirder for group chat, but that doesn't seem to be the case here.)

    It's simpler to manage, and far more performant than setting up for a range-based database query.

    You could do the date math you describe, but whenever you start asking about complex ranges, an alarm bell should be going off that there is probably a simpler way - and in this case there is!

  • Davy
    Davy Member
    Options

    Thank you both! 🙏