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

profile settings #322

Open
wants to merge 4 commits into
base: matrixcore
Choose a base branch
from
Open

profile settings #322

wants to merge 4 commits into from

Conversation

kloenk
Copy link
Member

@kloenk kloenk commented Mar 30, 2022

No description provided.

@kloenk kloenk force-pushed the matrixcore-profile-settings branch from 9f087fa to dd89f70 Compare March 31, 2022 09:52
@kloenk kloenk marked this pull request as ready for review March 31, 2022 12:44
Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

Looks good to me. There's a quite a few self.xyz where the self. isn't needed. Would be nice to drop them where possible. Other general comments inline 🙂


var body: some View {
List {
Section(header: Text("USER SETTINGS")) {
Copy link
Member

Choose a reason for hiding this comment

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

The heading should upper case this by itself I believe. Also if you're targeting iOS 15 (not sure) you can simply pass the string. Same comment for all the headers :)

Suggested change
Section(header: Text("USER SETTINGS")) {
Section("User Settings") {

}

// Password
Button("Change password", role: .destructive) {
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't mark this as destructive myself, if something bad is going to happen it should show an alert explaining this instead, otherwise changing password should probably feel like a safe operation to the user.

let nioAccount = store.accounts[account.userID!]!

if let displayName = changes["displayName"] as? String {
NioAccountStore.logger.debug("Changing displayName to \(displayName)")
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to actually log the new displayname? Always seems like a good habit to me to avoid logging personal data where possible. (Unless Logger redacts this string interpolation by default, in which case ignore me as I haven't used it in a while).

.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem {
Button(action: {
Copy link
Member

@pixlwave pixlwave Apr 1, 2022

Choose a reason for hiding this comment

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

As the label is simply text label, it's probably neater to

Button("Save") {
    // do stuff
}


// TODO: verified/unverified devices sections?
Section(header: Text("Devices")) {
ForEach(devices, id: \.deviceID) { device in
Copy link
Member

Choose a reason for hiding this comment

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

Side note: We should probably conform MatrixDevice to Identifiable.

.refreshable {
await self.updateDevices()
}
.toolbar {
Copy link
Member

Choose a reason for hiding this comment

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

Personally I'd consolidate the 2 toolbar modifiers into 1, but I can see why you might prefer 2 :)

private func delete(at offsets: IndexSet) {
let idsToDelete = offsets.map { self.devices[$0].deviceID }

_ = idsToDelete.compactMap { id 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
_ = idsToDelete.compactMap { id in
idsToDelete.forEach { id in

struct ProfileSettingsSecurityDeviceView: View {
let device: MatrixDevice

let subText: String
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
let subText: String
let subtext: String

Comment on lines +230 to +234
Button(action: {
self.setDisplayName()
}) {
Text("Save")
}
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
Button(action: {
self.setDisplayName()
}) {
Text("Save")
}
Button("Save") {
self.setDisplayName()
}

Comment on lines +71 to +84
if editMode == .active {
Button("Cancel") {
self.selection.removeAll()
withAnimation {
self.editMode = .inactive
}
}
} else {
Button("Edit") {
withAnimation {
self.editMode = .active
}
}
}
Copy link
Member

@pixlwave pixlwave Apr 1, 2022

Choose a reason for hiding this comment

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

Where possible, it's useful to update the parameters on a view rather than switching out the view for a new one:

Suggested change
if editMode == .active {
Button("Cancel") {
self.selection.removeAll()
withAnimation {
self.editMode = .inactive
}
}
} else {
Button("Edit") {
withAnimation {
self.editMode = .active
}
}
}
Button(editMode.isEditing ? "Cancel" : "Edit") {
if editMode.isEditing {
self.selection.removeAll()
withAnimation {
self.editMode = .inactive
}
} else {
withAnimation {
self.editMode = .active
}
}
}

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