linagora / tmail-flutter

A multi-platform (Flutter) application for reading your emails, with your favorite devices, using the JMAP protocol!
GNU Affero General Public License v3.0
323 stars 73 forks source link

Sorting: Emails should be sorted based on Email/query and not Email/get #2528

Open chibenwa opened 9 months ago

chibenwa commented 9 months ago

Description

Currently with advanced search options TMail sorts results based on their appearence order within the Email/get

But jmap spec says for EMail/get:

list: Foo[] An array of the Foo objects requested. [...] The results MAY be in a different order to the ids in the request arguments. [...]

We should rely on the order of Email/query in order to sort the display.

Side notes

Follow the sort order of Email/query first then if not good don't try dirty patches but discuss with me / backend team afterward

Proof

image

{
    "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
    "methodResponses": [
        [
            "Email/query",
            {
                "accountId": "51e6371779b54390bf5970559c64c2725da1d3b8a3c548a97ddf98522822ca75",
                "queryState": "51995620",
                "canCalculateChanges": false,
                "ids": [
                    "928451d0-bb7f-11ee-9616-9507dd070aac",
                    "daeecdc0-bc46-11ee-afc2-653991ada5df",
                    "2d459580-b919-11ee-852f-45d865aafa43",
                    "b76e5900-b918-11ee-852f-45d865aafa43",
                    "2da7b2b0-b919-11ee-852f-45d865aafa43",
                    "669c26b0-bebd-11ee-853d-bd2e90c13582",
                    "65df9570-bbf4-11ee-b24c-875f76490a3c"
                ],
                "position": 0
            },
            "c0"
        ],
        [
            "Email/get",
            {
                "accountId": "51e6371779b54390bf5970559c64c2725da1d3b8a3c548a97ddf98522822ca75",
                "notFound": [],
                "state": "359de9b0-bf7e-11ee-b077-0518d8ae7fe1",
                "list": [
                    {
                        "replyTo": [
                            {
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "header:X-MEETING-UID:asText": null,
                        "preview": "Test",
                        "to": [
                            {
                                "name": "btellier@linagora.com",
                                "email": "btellier@linagora.com"
                            }
                        ],
                        "id": "b76e5900-b918-11ee-852f-45d865aafa43",
                        "mailboxIds": {
                            "3aa8cff0-b6e2-11ee-95b9-49fc99c32643": true
                        },
                        "from": [
                            {
                                "name": "Test SFR15",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "keywords": {
                            "$seen": true
                        },
                        "receivedAt": "2024-01-22T11:23:50Z",
                        "sentAt": "2024-01-22T11:23:50Z",
                        "hasAttachment": false,
                        "subject": "Test",
                        "size": 895
                    },
                    {
                        "header:X-MEETING-UID:asText": null,
                        "preview": "This is an e-mail message sent automatically by Microsoft Outlook while testing the settings for your account.",
                        "to": [
                            {
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "id": "928451d0-bb7f-11ee-9616-9507dd070aac",
                        "mailboxIds": {
                            "bf407aa0-b6d4-11ee-83a2-13412608edb2": true
                        },
                        "from": [
                            {
                                "name": "Microsoft Outlook",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "keywords": {
                            "nonjunk": true,
                            "$seen": true
                        },
                        "receivedAt": "2024-01-25T12:45:08Z",
                        "hasAttachment": false,
                        "subject": "Microsoft Outlook Test Message",
                        "size": 1274
                    },
                    {
                        "size": 66859,
                        "replyTo": [
                            {
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "header:X-MEETING-UID:asText": null,
                        "preview": "",
                        "id": "65df9570-bbf4-11ee-b24c-875f76490a3c",
                        "mailboxIds": {
                            "3aaf5fa0-b6e2-11ee-95b9-49fc99c32643": true
                        },
                        "from": [
                            {
                                "name": "Test SFR15",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "keywords": {
                            "$draft": true,
                            "$seen": true
                        },
                        "receivedAt": "2024-01-26T02:41:25Z",
                        "sentAt": "2024-01-26T02:41:24Z",
                        "hasAttachment": true
                    },
                    {
                        "replyTo": [
                            {
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "header:X-MEETING-UID:asText": null,
                        "preview": "Test to me On Jan 22, 2024 10:44 AM, from Comptetest15.linagora@avocat.fr Ádnkasnkndk Ádasda sdas đâsd",
                        "to": [
                            {
                                "name": "comptetest15.linagora@avocat.fr",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "id": "2d459580-b919-11ee-852f-45d865aafa43",
                        "mailboxIds": {
                            "3aa8cff0-b6e2-11ee-95b9-49fc99c32643": true
                        },
                        "from": [
                            {
                                "name": "Test SFR15",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "keywords": {
                            "$seen": true
                        },
                        "receivedAt": "2024-01-22T11:27:07Z",
                        "sentAt": "2024-01-22T11:27:07Z",
                        "hasAttachment": false,
                        "subject": "Re: NOTI NOTI NOTI SYNC",
                        "size": 2625
                    },
                    {
                        "replyTo": [
                            {
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "header:X-MEETING-UID:asText": null,
                        "preview": "",
                        "to": [
                            {
                                "name": "btellier@linagora.com",
                                "email": "btellier@linagora.com"
                            }
                        ],
                        "id": "669c26b0-bebd-11ee-853d-bd2e90c13582",
                        "mailboxIds": {
                            "3aa8cff0-b6e2-11ee-95b9-49fc99c32643": true
                        },
                        "from": [
                            {
                                "name": "Test SFR15",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "keywords": {
                            "$seen": true
                        },
                        "receivedAt": "2024-01-29T15:45:17Z",
                        "sentAt": "2024-01-29T15:45:17Z",
                        "hasAttachment": false,
                        "subject": "Test outgoing",
                        "size": 875
                    },
                    {
                        "header:X-MEETING-UID:asText": null,
                        "preview": "This is an e-mail message sent automatically by Microsoft Outlook while testing the settings for your account.",
                        "to": [
                            {
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "id": "daeecdc0-bc46-11ee-afc2-653991ada5df",
                        "mailboxIds": {
                            "bf407aa0-b6d4-11ee-83a2-13412608edb2": true
                        },
                        "from": [
                            {
                                "name": "Microsoft Outlook",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "keywords": {
                            "$seen": true
                        },
                        "receivedAt": "2024-01-26T12:31:40Z",
                        "hasAttachment": false,
                        "subject": "Microsoft Outlook Test Message",
                        "size": 1274
                    },
                    {
                        "replyTo": [
                            {
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "header:X-MEETING-UID:asText": null,
                        "preview": "Test to me On Jan 22, 2024 10:44 AM, from Comptetest15.linagora@avocat.fr Ádnkasnkndk Ádasda sdas đâsd",
                        "to": [
                            {
                                "name": "comptetest15.linagora@avocat.fr",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "id": "2da7b2b0-b919-11ee-852f-45d865aafa43",
                        "mailboxIds": {
                            "bf407aa0-b6d4-11ee-83a2-13412608edb2": true
                        },
                        "from": [
                            {
                                "name": "Test SFR15",
                                "email": "comptetest15.linagora@avocat.fr"
                            }
                        ],
                        "keywords": {
                            "$seen": true
                        },
                        "receivedAt": "2024-01-22T11:27:08Z",
                        "sentAt": "2024-01-22T11:27:07Z",
                        "hasAttachment": false,
                        "subject": "Re: NOTI NOTI NOTI SYNC",
                        "size": 2794
                    }
                ]
            },
            "c1"
        ]
    ]
}

b76e5900-b918-11ee-852f-45d865aafa43 is displayed on top while James says not to do this...

chibenwa commented 2 days ago

Regression.

Given I sort by sender name my inbox, got the following request:

image

image

If I open the first element in the list the ID is 67ec9fa0-2d57-11ef-a845-bb314806fd1 so the order is taken from Email/get request and not from Email/query request as it should.

chibenwa commented 2 days ago

https://tmail.linagora.com/ version 0.13.5