Skip to content

Commit

Permalink
Don't display subFolders indent in MoveFragment when searching for a …
Browse files Browse the repository at this point in the history
…folder
  • Loading branch information
KevinBoulongne committed Jun 7, 2024
1 parent 0b1bcc4 commit b83fdcc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/com/infomaniak/mail/data/models/Folder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class Folder : RealmObject, Cloneable {
@Transient
@Ignore
var shouldDisplayDivider: Boolean = false
@Transient
@Ignore
var shouldDisplayIndent: Boolean = true
//endregion

private val _parents by backlinks(Folder::children)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ class FolderAdapter @Inject constructor(
}

@SuppressLint("NotifyDataSetChanged")
fun setFolders(newFolders: List<Folder>, newCurrentFolderId: String? = null) = runCatchingRealm {
fun setFolders(newFolders: List<Folder>, newCurrentFolderId: String? = null, isSearching: Boolean) = runCatchingRealm {

fun foldersWithDivider(): List<Folder> {
fun foldersWithDividersAndIndents(): List<Folder> {
var isFirstCustomFolder = true
return newFolders.map { folder ->
folder.clone().apply {
Expand All @@ -191,6 +191,7 @@ class FolderAdapter @Inject constructor(
} else {
false
}
shouldDisplayIndent = folder.isRoot || !isSearching
}
}
}
Expand All @@ -211,7 +212,7 @@ class FolderAdapter @Inject constructor(
}

newCurrentFolderId?.let { currentFolderId = it }
submitList(foldersWithDivider())
submitList(foldersWithDividersAndIndents())
if (isInMenuDrawer) notifyCollapsableFolders()
}

Expand Down Expand Up @@ -252,7 +253,8 @@ class FolderAdapter @Inject constructor(
oldFolder.threads.count() == newFolder.threads.count() &&
oldFolder.isHidden == newFolder.isHidden &&
oldFolder.canBeCollapsed == newFolder.canBeCollapsed &&
oldFolder.shouldDisplayDivider == newFolder.shouldDisplayDivider
oldFolder.shouldDisplayDivider == newFolder.shouldDisplayDivider &&
oldFolder.shouldDisplayIndent == newFolder.shouldDisplayIndent
}.getOrDefault(false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ class MoveFragment : Fragment() {

private fun toggleFolderListsVisibility(query: String?, allFolders: List<Folder>) {
isSearching = !query.isNullOrBlank()
if (!isSearching) folderAdapter.setFolders(allFolders, moveViewModel.currentFolderId)
if (!isSearching) folderAdapter.setFolders(allFolders, moveViewModel.currentFolderId, isSearching)
}

private fun observeSearchResults() = with(moveViewModel) {
filterResults.observe(viewLifecycleOwner) { folders ->
if (isSearching) folderAdapter.setFolders(folders, currentFolderId)
if (isSearching) folderAdapter.setFolders(folders, currentFolderId, isSearching)
}
}

Expand Down

0 comments on commit b83fdcc

Please sign in to comment.