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

feat: Edit and delete folders #1605

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

feat: Edit and delete folders #1605

wants to merge 12 commits into from

Conversation

BaptGrv
Copy link
Contributor

@BaptGrv BaptGrv commented Nov 1, 2024

No description provided.

Copy link

sonarqubecloud bot commented Nov 1, 2024

Copy link

github-actions bot commented Nov 1, 2024

Found 0 unused code occurences

Expand
* No unused code detected.

Copy link
Member

@PhilippeWeidmann PhilippeWeidmann left a comment

Choose a reason for hiding this comment

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

See comments +
Also only commit the string you modified/added but not the others

return try await perform(request: authenticatedRequest(
.modifyFolder(mailboxUuid: mailbox.uuid, folderId: folder.remoteId),
method: .post,
parameters: newName
Copy link
Member

Choose a reason for hiding this comment

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

You can use parameters directly instead of creating a struct

Suggested change
parameters: newName
parameters: ["name": name]

Comment on lines 131 to 139
if folder != nil {
folderName = folder!.name
}
switch mode {
case .modify:
isModifyView = true
default:
return
}
Copy link
Member

Choose a reason for hiding this comment

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

Use init of the view instead of onAppear

@@ -37,10 +37,13 @@ struct CreateFolderView: View {

@State private var folderName = ""
@State private var error: FolderError?
@State private var isModifyView = false
Copy link
Member

Choose a reason for hiding this comment

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

You can check mode instead of declaring a new State

Comment on lines 110 to 117
if folder != nil && isModifyView {
await tryOrDisplayError {
try await mailboxManager.modifyFolder(
name: folderName,
folder: folder!
)
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Use guard to unwrap folder + directly check mode

hasSubFolders = folders.contains { !$0.children.isEmpty }
}

var body: some View {
VStack(spacing: 0) {
ForEach(folders) { folder in

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change


private let folders: [NestableFolder]
private let hasSubFolders: Bool
private let isUserFoldersList: Bool
Copy link
Member

Choose a reason for hiding this comment

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

Do not use isUserFoldersList but check for folder.role. If folder has a role do not allow rename.

FolderCell(folder: folder,
currentFolderId: mainViewState.selectedFolder.remoteId,
canCollapseSubFolders: hasSubFolders,
matomoCategory: .menuDrawer)
.background(RoundedRectangle(cornerRadius: 10).fill(MailResourcesAsset.backgroundSecondaryColor.swiftUIColor))
Copy link
Member

Choose a reason for hiding this comment

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

Check if we have a constant somewhere for cornerRadius

}
}
}
.customAlert(isPresented: $isShowingCreateFolderAlert) {
Copy link
Member

Choose a reason for hiding this comment

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

Use .customAlert(item: $currentFolder) instead of a Bool + Folder for State


@FocusState private var isFocused

let mode: Mode
let folder: Folder?
Copy link
Member

Choose a reason for hiding this comment

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

In an other comment I suggested adding an init. In the init you can use a default arg

Copy link
Member

Choose a reason for hiding this comment

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

Wont be needed after my other comment

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants