diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-21 16:53:17 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-21 16:53:17 +0000 |
| commit | f79014235e85554e3661b3f2a02b8fa88bc192ff (patch) | |
| tree | fceec3ff2df212148a3420af7cef81a3f818463e /src/bin/ngit/sub_commands/send.rs | |
| parent | 91b0eac4daf92b7b740267ef203a1a8ba591974b (diff) | |
feat(login): overhaul login experience
* simplify login menu, making it more accessable to newcomers and
easier to select remote signer options
* enable `ngit login` to work from anywhere (not just a git repo)
* assume fresh login details saved to global git config but fallback
to local repository
* maintain local repository login via `ngit login --local`
* maintain login via CLI arguments eg `ngit send --nsec nsec123`
* nudge users to remember nsec when pasting in ncryptsec for a
better UX, whilst maintaining the option to be prompted for
password everytime
* create placeholder menu items for help menu and create account
Diffstat (limited to 'src/bin/ngit/sub_commands/send.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/send.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index fe2952f..114a021 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs | |||
| @@ -10,12 +10,12 @@ use nostr::{ | |||
| 10 | use nostr_sdk::hashes::sha1::Hash as Sha1Hash; | 10 | use nostr_sdk::hashes::sha1::Hash as Sha1Hash; |
| 11 | 11 | ||
| 12 | use crate::{ | 12 | use crate::{ |
| 13 | cli::Cli, | 13 | cli::{extract_signer_cli_arguments, Cli}, |
| 14 | cli_interactor::{ | 14 | cli_interactor::{ |
| 15 | Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms, PromptMultiChoiceParms, | 15 | Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms, PromptMultiChoiceParms, |
| 16 | }, | 16 | }, |
| 17 | client::{ | 17 | client::{ |
| 18 | fetching_with_report, get_events_from_cache, get_repo_ref_from_cache, Client, Connect, | 18 | fetching_with_report, get_events_from_local_cache, get_repo_ref_from_cache, Client, Connect, |
| 19 | }, | 19 | }, |
| 20 | git::{identify_ahead_behind, Repo, RepoActions}, | 20 | git::{identify_ahead_behind, Repo, RepoActions}, |
| 21 | git_events::{event_is_patch_set_root, event_tag_from_nip19_or_hex}, | 21 | git_events::{event_is_patch_set_root, event_tag_from_nip19_or_hex}, |
| @@ -175,21 +175,18 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re | |||
| 175 | } else { | 175 | } else { |
| 176 | None | 176 | None |
| 177 | }; | 177 | }; |
| 178 | let (signer, user_ref) = login::launch( | 178 | |
| 179 | &git_repo, | 179 | let (signer, user_ref, _) = login::login_or_signup( |
| 180 | &cli_args.bunker_uri, | 180 | &Some(&git_repo), |
| 181 | &cli_args.bunker_app_key, | 181 | &extract_signer_cli_arguments(cli_args).unwrap_or(None), |
| 182 | &cli_args.nsec, | ||
| 183 | &cli_args.password, | 182 | &cli_args.password, |
| 184 | Some(&client), | 183 | Some(&client), |
| 185 | false, | ||
| 186 | false, | ||
| 187 | ) | 184 | ) |
| 188 | .await?; | 185 | .await?; |
| 189 | 186 | ||
| 190 | client.set_signer(signer.clone()).await; | 187 | client.set_signer(signer.clone()).await; |
| 191 | 188 | ||
| 192 | let repo_ref = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await?; | 189 | let repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await?; |
| 193 | 190 | ||
| 194 | // oldest first | 191 | // oldest first |
| 195 | commits.reverse(); | 192 | commits.reverse(); |
| @@ -228,7 +225,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re | |||
| 228 | 225 | ||
| 229 | send_events( | 226 | send_events( |
| 230 | &client, | 227 | &client, |
| 231 | git_repo_path, | 228 | Some(git_repo_path), |
| 232 | events.clone(), | 229 | events.clone(), |
| 233 | user_ref.relays.write(), | 230 | user_ref.relays.write(), |
| 234 | repo_ref.relays.clone(), | 231 | repo_ref.relays.clone(), |
| @@ -370,9 +367,11 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to( | |||
| 370 | marker: _, | 367 | marker: _, |
| 371 | public_key: _, | 368 | public_key: _, |
| 372 | }) => { | 369 | }) => { |
| 373 | let events = | 370 | let events = get_events_from_local_cache( |
| 374 | get_events_from_cache(git_repo_path, vec![nostr::Filter::new().id(*event_id)]) | 371 | git_repo_path, |
| 375 | .await?; | 372 | vec![nostr::Filter::new().id(*event_id)], |
| 373 | ) | ||
| 374 | .await?; | ||
| 376 | 375 | ||
| 377 | if let Some(first) = events.iter().find(|e| e.id.eq(event_id)) { | 376 | if let Some(first) = events.iter().find(|e| e.id.eq(event_id)) { |
| 378 | if event_is_patch_set_root(first) { | 377 | if event_is_patch_set_root(first) { |