SebastienBtr/Dash-Chat-2

Inverting the chat

Closed this issue · 9 comments

funjay commented

Hi, i searched all through the documentation.

Can someone help me with inverting the chats? eg

having the last message down and not up ( earlier messages up ) - like whatsapp

thanks

Hey, check the example project to see examples, messages are in ascending order like any messaging app on those examples. Your issue is most likely in the way you're fetching your data, the list of messages you are providing is probably in the wrong order

funjay commented

What field is used for sorting. or do i manually sort it? what am i doing wrong? I was thinking the createdAT will be used by dash?

There is nothing to sort your data in DashChat, please take a look at the examples to understand how to use it.
If you see your messages in the wrong order then fetch them in the opposite order, I don't know what DB/Backend you're using but in SQL you'd change your ORDER BY close

funjay commented

using the example data, i adjusted time and text to reflect latest messages,
and i get the same thing. Check attachment . the newer or latest messages are up , thats opposite what i wanted. in the dash (former) there was a flag to turn inverted to false
Screenshot from 2023-05-13 19-12-59

I tried without backend, the messages are pilling up , my chat is inverted, the load earlier arrow is at the bottom not at the top

If you send your code maybe I can tell you what you're doing wrong, but if you run the example project you'll see that everything is in the right order. Run the example project, play around and I'm sure you'll understand how it works.
The arrow at the bottom isn't the load earlier, it's the back-to-bottom button

funjay commented

Trying out a potential fix, i think i might have found it.. but editing directly on cache files is bad to me, cos i might forget
yeaa i found the fix

funjay commented

I can Open a PR if the team feels it is a needed feature

  1. we can reintroduce the inverted option
  2. or we can make the Dashchat put latest message below and not above -

Option 1 will be for flexibility, for those who also want their chats to pile upwards and not downwards like whatsapp and other chat engines

funjay commented

TO fix

remove the option below

reverse: true,

from dash_chat_2-0.0.16/lib/src/widgets/message_list/message_list.dart

and it will be fixed

we can reintroduce the inverted option

  • No

or we can make the Dashchat put latest message below and not above -

  • It's already what it does

Again, please run the example project! There is no issue in DashChat but an issue in your implementation.

The order of the chats is controlled by the order of your data, if the messages don't show up in your desired order you can simply reverse your list of messages. Dashchat has been made to put older messages at the top and the latest messages at the bottom, as shown in all examples and on the readme screenshots.

1- Run the example project, you'll see that the messages are in the order that you want and you'll understand how your data should be sorted to work
2- If you're still not able to make it work in your project, provide a full code sample to reproduce it and I'll be able to help you fix your issue

I'm closing the issue as there is nothing wrong with DashChat and there is no more help I can give in the current state