-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernelkind (6): post quote reposts impl make PostActionExecutor for code reuse add repost button address PR comments make views pure minor cleanup
- Loading branch information
Showing
14 changed files
with
296 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use enostr::{FilledKeypair, RelayPool}; | ||
use nostrdb::Note; | ||
use tracing::info; | ||
|
||
use crate::{draft::Draft, post::NewPost, ui::note::PostAction}; | ||
|
||
pub struct PostActionExecutor {} | ||
|
||
impl PostActionExecutor { | ||
pub fn execute<'a>( | ||
poster: FilledKeypair<'_>, | ||
action: &'a PostAction, | ||
pool: &mut RelayPool, | ||
draft: &mut Draft, | ||
get_note: impl Fn(&'a NewPost, &[u8; 32]) -> Note<'a>, | ||
) { | ||
match action { | ||
PostAction::Post(np) => { | ||
let note = get_note(np, &poster.secret_key.to_secret_bytes()); | ||
|
||
let raw_msg = format!("[\"EVENT\",{}]", note.json().unwrap()); | ||
info!("sending {}", raw_msg); | ||
pool.send(&enostr::ClientMessage::raw(raw_msg)); | ||
draft.clear(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.