Open
Conversation
9e6f59d to
b36d667
Compare
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>
b36d667 to
dc34550
Compare
SystemKeeper
requested changes
Apr 19, 2026
Collaborator
SystemKeeper
left a comment
There was a problem hiding this comment.
Missing database bump
Collaborator
|
I have a suggestion to do it a little different: In 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 // 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 unmanagedRoomsThen 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. |
Member
jancborchardt
left a comment
There was a problem hiding this comment.
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. :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.