Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FolderCell): invalidated folder at startup would crash the app #920

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Mail/Views/Menu Drawer/FolderListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,23 @@ import SwiftUI

struct NestableFolder: Identifiable {
var id: String {
content.id
guard !content.isInvalidated else {
return UUID().uuidString
}

return content.id
}

let content: Folder
let children: [NestableFolder]

/// A view on `children` data, only valid Realm objects
var displayableChildren: [NestableFolder] {
children.filter { element in
!element.content.isInvalidated
}
}

static func createFoldersHierarchy(from folders: [Folder]) -> [Self] {
var parentFolders = [NestableFolder]()

Expand Down
4 changes: 2 additions & 2 deletions Mail/Views/Menu Drawer/Folders/FolderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ struct FolderCell: View {
}
}

if folder.content.isExpanded || cellType == .move {
ForEach(folder.children) { child in
if !folder.content.isInvalidated && folder.content.isExpanded || cellType == .move {
ForEach(folder.displayableChildren) { child in
FolderCell(
folder: child,
level: level + 1,
Expand Down
Loading