-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: master
Are you sure you want to change the base?
Conversation
2c5c6b7
to
b899e7d
Compare
Quality Gate passedIssues Measures |
Found 0 unused code occurences Expand
|
18e49bf
to
3a23bbd
Compare
00c1d3a
to
e24d162
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
parameters: newName | |
parameters: ["name": name] |
if folder != nil { | ||
folderName = folder!.name | ||
} | ||
switch mode { | ||
case .modify: | ||
isModifyView = true | ||
default: | ||
return | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
if folder != nil && isModifyView { | ||
await tryOrDisplayError { | ||
try await mailboxManager.modifyFolder( | ||
name: folderName, | ||
folder: folder! | ||
) | ||
} | ||
} else { |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
private let folders: [NestableFolder] | ||
private let hasSubFolders: Bool | ||
private let isUserFoldersList: Bool |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Quality Gate passedIssues Measures |
No description provided.