Skip to content

Commit

Permalink
Sort folders alphabetically in special folders screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cketti committed Dec 19, 2023
1 parent cba9ca3 commit 6de9d8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class GetSpecialFolderOptions(
?: error("No incoming server settings available")

val remoteFolders = folderFetcher.getFolders(serverSettings, authStateStorage)
.sortedWith(
compareByDescending<RemoteFolder> { it.type == FolderType.INBOX }
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.displayName },
)

SpecialFolderOptions(
archiveSpecialFolderOptions = mapByFolderType(FolderType.ARCHIVE, remoteFolders),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,31 +124,31 @@ class GetSpecialFolderOptionsTest {

assertThat(folders.archiveSpecialFolderOptions[0]).isEqualTo(
SpecialFolderOption.Special(
remoteFolder = ARCHIVE_FOLDER_2,
remoteFolder = ARCHIVE_FOLDER_1,
isAutomatic = true,
),
)
assertThat(folders.draftsSpecialFolderOptions[0]).isEqualTo(
SpecialFolderOption.Special(
remoteFolder = DRAFTS_FOLDER_2,
remoteFolder = DRAFTS_FOLDER_1,
isAutomatic = true,
),
)
assertThat(folders.sentSpecialFolderOptions[0]).isEqualTo(
SpecialFolderOption.Special(
remoteFolder = SENT_FOLDER_2,
remoteFolder = SENT_FOLDER_1,
isAutomatic = true,
),
)
assertThat(folders.spamSpecialFolderOptions[0]).isEqualTo(
SpecialFolderOption.Special(
remoteFolder = SPAM_FOLDER_2,
remoteFolder = SPAM_FOLDER_1,
isAutomatic = true,
),
)
assertThat(folders.trashSpecialFolderOptions[0]).isEqualTo(
SpecialFolderOption.Special(
remoteFolder = TRASH_FOLDER_2,
remoteFolder = TRASH_FOLDER_1,
isAutomatic = true,
),
)
Expand Down Expand Up @@ -299,6 +299,8 @@ class GetSpecialFolderOptionsTest {
SpecialFolderOption.Special(
remoteFolder = DRAFTS_FOLDER_1,
),
SpecialFolderOption.Regular(REGULAR_FOLDER_1),
SpecialFolderOption.Regular(REGULAR_FOLDER_2),
SpecialFolderOption.Special(
remoteFolder = SENT_FOLDER_1,
),
Expand All @@ -308,8 +310,6 @@ class GetSpecialFolderOptionsTest {
SpecialFolderOption.Special(
remoteFolder = TRASH_FOLDER_1,
),
SpecialFolderOption.Regular(REGULAR_FOLDER_1),
SpecialFolderOption.Regular(REGULAR_FOLDER_2),
).toTypedArray()
}

Expand Down

0 comments on commit 6de9d8c

Please sign in to comment.