Skip to content

feat: Conversations sorting#2453

Open
Ivansss wants to merge 7 commits intomainfrom
feat/noid/room-sorting-settings
Open

feat: Conversations sorting#2453
Ivansss wants to merge 7 commits intomainfrom
feat/noid/room-sorting-settings

Conversation

@Ivansss
Copy link
Copy Markdown
Member

@Ivansss Ivansss commented Apr 7, 2026

iOS 26+ iOS 26+ (active filter) iPads or prior iOS versions iPads or prior iOS versions (active filter)
grafik grafik grafik grafik

@Ivansss Ivansss force-pushed the feat/noid/room-sorting-settings branch from 9e6f59d to b36d667 Compare April 10, 2026 12:20
@Ivansss Ivansss requested a review from SystemKeeper April 10, 2026 12:21
@Ivansss Ivansss marked this pull request as ready for review April 10, 2026 12:21
Ivansss added 7 commits April 16, 2026 17:00
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
…nu for all platforms and iOS versions

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
@Ivansss Ivansss force-pushed the feat/noid/room-sorting-settings branch from b36d667 to dc34550 Compare April 16, 2026 15:49
Copy link
Copy Markdown
Collaborator

@SystemKeeper SystemKeeper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing database bump

@SystemKeeper
Copy link
Copy Markdown
Collaborator

I have a suggestion to do it a little different:

In NCRoom.swift:

extension Array where Element == NCRoom {

    mutating func sortRooms(withGroupMode groupMode: NCRoomGroupMode, withSortOrder sortOrder: NCRoomSortOrder) {
        self.sort { (first: NCRoom, second: NCRoom) in
            // 1. Favorites
            if first.isFavorite != second.isFavorite {
                return first.isFavorite
            }

            // 2. Group mode
            if groupMode == .groupFirst || groupMode == .privateFirst {
                let firstIsOneToOne = (first.type == .oneToOne || first.type == .formerOneToOne)
                let secondIsOneToOne = (second.type == .oneToOne || second.type == .formerOneToOne)

                if firstIsOneToOne != secondIsOneToOne {
                    let oneToOneFirst = groupMode == .privateFirst
                    return firstIsOneToOne == oneToOneFirst
                }
            }

            // 3. Sort order
            if sortOrder == .alphabetical {
                return first.displayName.localizedCaseInsensitiveCompare(second.displayName) == .orderedAscending
            }

            // Default: Recent activity
            return first.lastActivity > second.lastActivity
        }
    }

}

In NCDatabaseManager.swift:

        // Sort rooms
        let capabilities = NCDatabaseManager.sharedInstance().serverCapabilities(forAccountId: accountId)
        var groupMode: NCRoomGroupMode = .none
        var sortOrder: NCRoomSortOrder = .activity

        if let capabilities {
            groupMode = NCRoomGroupMode(rawValue: capabilities.roomsGroupMode) ?? groupMode
            sortOrder = NCRoomSortOrder(rawValue: capabilities.roomsSortOrder) ?? sortOrder
        }

        unmanagedRooms.sortRooms(withGroupMode: groupMode, withSortOrder: sortOrder)

        return unmanagedRooms

Then we could also test the sorting:

    private func createRoom(withDisplayName displayName: String, withType type: NCRoomType, isFavorite favorite: Bool, withLastActivity lastActivity: Int) -> NCRoom {
        let room = NCRoom()
        room.displayName = displayName
        room.type = type
        room.isFavorite = favorite
        room.lastActivity = lastActivity

        return room
    }

    func testRoomSort() throws {
        let favOneToOne = self.createRoom(withDisplayName: "FavRoom1 1-1", withType: .oneToOne, isFavorite: true, withLastActivity: 0)
        let favGroup = self.createRoom(withDisplayName: "FavRoom1 Group", withType: .group, isFavorite: true, withLastActivity: 0)
        let room1 = self.createRoom(withDisplayName: "Room1", withType: .group, isFavorite: false, withLastActivity: 1)
        let room2 = self.createRoom(withDisplayName: "Room2", withType: .group, isFavorite: false, withLastActivity: 2)
        let activity1 = self.createRoom(withDisplayName: "Activity1", withType: .oneToOne, isFavorite: false, withLastActivity: 123)
        let activity2 = self.createRoom(withDisplayName: "Activity2", withType: .oneToOne, isFavorite: false, withLastActivity: 456)

        let startArray = [
            activity2, activity1,
            favGroup, favOneToOne,
            room2, room1
        ]

        var test1Begin = startArray
        test1Begin.sortRooms(withGroupMode: .privateFirst, withSortOrder: .activity)

        let test1Expected = [
            favOneToOne, favGroup, activity2, activity1, room2, room1
        ]

        XCTAssertEqual(test1Begin, test1Expected)
    }

It seems to work fine, although from a gut feeling something is missing in the sort method.

Copy link
Copy Markdown
Member

@jancborchardt jancborchardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI-wise it’s good, but it’s making the menu very complex. Do we really need all these sortings/filters? cc @nimishavijay

  • Alphabetical sorting: Is not present in other platforms like Teams, Discord, Signal. It is also quite arbitrary
  • No grouping / Private first / Group first: If we move to split private and groups, why don’t we fully commit to it?
  • The filters are quite common and useful, but there we could also cut the "No filter" entry. If none of the 3 is set, that is kind of understood.

Of course this would need to be the same across Android and web too. If there has been discussion around this, let me know for context. :)

@jancborchardt jancborchardt moved this to 🏗️ At engineering in 🖍 Design team Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗️ At engineering

Development

Successfully merging this pull request may close these issues.

3 participants