-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow setting name of FactorSources #305
Changes from 1 commit
c755e29
0a4e11c
f55142b
f16e133
ac8b29f
3015174
a157afc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,10 @@ impl BaseBaseIsFactorSource for OffDeviceMnemonicFactorSource { | |
fn name(&self) -> String { | ||
self.hint.label.value.clone() | ||
} | ||
|
||
fn set_name(&mut self, updated: String) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor improvement would be to change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and inside this function you do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did remember this suggestion from previous PR review 🙂 I decided not to include it in this case since tests are very simple anyway, and in the end we add one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is unfortunate that Rust is not as great as Swift when it comes to method with same name but different types - in Swift we could have written such a method on the protocol - the trait - and allow str/String. here it would be a collision. |
||
self.hint.label.value = updated; | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
|
@@ -158,6 +162,9 @@ mod tests { | |
|
||
#[test] | ||
fn name() { | ||
assert_eq!(SUT::sample().name(), "Story about a horse"); | ||
let mut sut = SUT::sample(); | ||
assert_eq!(sut.name(), "Story about a horse"); | ||
sut.set_name("Thrilled with a shark".to_string()); | ||
assert_eq!(sut.name(), "Thrilled with a shark"); | ||
} | ||
} |
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.
This is nice, but I think we can go a step further and also make the update in the Profile itself, so maybe this API should have the factor source id to be updated.
Or your intention is different?
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.
I was thinking of handling it the same way we handle Account name updates, but guess we can directly do altogether. Will update
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.
That is more legacy :), we should migrate how we rename accounts sometime to be handled in Sargon.
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.
actually I am not sure if it is better to have a function that updates the
name: String
of a givenfactor_source_id: FactorSourceId
. Considering Hosts we will already have access to the actualFactorSource
and that we already have a function that updates aFactorSource
, seems pointless to send theid
just to have Sargon fetch it from the Profile.Maybe instead the function should be like this
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.
Sure that also works, the main idea is to have the Profile mutation in Sargon. You might want to return the update FactorSource as response of this function.