From a38fcb6d022daa47d913c10930f875987419e563 Mon Sep 17 00:00:00 2001 From: Eric P Date: Thu, 12 Dec 2024 00:35:31 -0600 Subject: [PATCH] Add setting to toggle showing of hosted wallet ids --- dbif/src/lib.rs | 19 +++++++++++++++---- src/handler.rs | 2 ++ webroot/script/helipad.js | 8 +++++++- webroot/template/general-settings.hbs | 4 ++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/dbif/src/lib.rs b/dbif/src/lib.rs index 4747555..b093734 100644 --- a/dbif/src/lib.rs +++ b/dbif/src/lib.rs @@ -106,6 +106,7 @@ pub struct SettingsRecord { pub play_pew: bool, pub custom_pew_file: Option, pub resolve_nostr_refs: bool, + pub show_hosted_wallet_ids: bool, } #[derive(Debug, Default, Clone)] @@ -384,6 +385,10 @@ pub fn create_database(filepath: &String) -> Result> { println!("Nostr refs setting added."); } + if conn.execute("ALTER TABLE settings ADD COLUMN show_hosted_wallet_ids integer DEFAULT 0", []).is_ok() { + println!("Hosted wallet id setting added."); + } + //Create the webhooks table match conn.execute( "CREATE TABLE IF NOT EXISTS webhooks ( @@ -1293,7 +1298,8 @@ pub fn load_settings_from_db(filepath: &String) -> Result Result Result Err(Box::new(e)), } @@ -1340,10 +1348,11 @@ pub fn save_settings_to_db(filepath: &String, settings: &SettingsRecord) -> Resu hide_boosts_below, play_pew, custom_pew_file, - resolve_nostr_refs + resolve_nostr_refs, + show_hosted_wallet_ids ) VALUES - (1, ?1, ?2, ?3, ?4, ?5, ?6, ?7) + (1, ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8) ON CONFLICT(idx) DO UPDATE SET show_received_sats = excluded.show_received_sats, show_split_percentage = excluded.show_split_percentage, @@ -1351,7 +1360,8 @@ pub fn save_settings_to_db(filepath: &String, settings: &SettingsRecord) -> Resu hide_boosts_below = excluded.hide_boosts_below, play_pew = excluded.play_pew, custom_pew_file = excluded.custom_pew_file, - resolve_nostr_refs = excluded.resolve_nostr_refs + resolve_nostr_refs = excluded.resolve_nostr_refs, + show_hosted_wallet_ids = excluded.show_hosted_wallet_ids "#, params![ settings.show_received_sats, @@ -1361,6 +1371,7 @@ pub fn save_settings_to_db(filepath: &String, settings: &SettingsRecord) -> Resu settings.play_pew, settings.custom_pew_file, settings.resolve_nostr_refs, + settings.show_hosted_wallet_ids, ] ) { Ok(_) => { diff --git a/src/handler.rs b/src/handler.rs index 475e40e..d952dfa 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -752,6 +752,7 @@ pub struct GeneralSettingsMultipart { hide_boosts_below: Option, play_pew: Option, resolve_nostr_refs: Option, + show_hosted_wallet_ids: Option, // The `unlimited arguments` means that this field will be limited to the // total size of the request body. If you want to limit the size of this @@ -783,6 +784,7 @@ pub async fn general_settings_save( settings.hide_boosts_below = hide_boosts_below; settings.play_pew = parts.play_pew.unwrap_or(false); settings.resolve_nostr_refs = parts.resolve_nostr_refs.unwrap_or(false); + settings.show_hosted_wallet_ids = parts.show_hosted_wallet_ids.unwrap_or(false); if !settings.hide_boosts { settings.hide_boosts_below = None; diff --git a/webroot/script/helipad.js b/webroot/script/helipad.js index 5e9362d..bc81433 100644 --- a/webroot/script/helipad.js +++ b/webroot/script/helipad.js @@ -114,6 +114,7 @@ $(document).ready(function () { let boostRemotePodcast = element.remote_podcast; let boostRemoteEpisode = element.remote_episode; let boostReplySent = element.reply_sent; + let boostCustomValue = element.custom_value; let boostTlv = {}; let boostReplyAddress; let boostReplyCustomKey; @@ -178,6 +179,11 @@ $(document).ready(function () { } } + let boostWalletInfo = ''; + if (settings.show_hosted_wallet_ids && boostCustomValue) { + boostWalletInfo = `[Wallet #${escapeHTML(boostCustomValue)}]`; + } + //Show clock icon for automated boosts if (boostTlv && boostTlv.action == "auto") { boostDisplayAmount = ` @@ -236,7 +242,7 @@ $(document).ready(function () {
- ${boostDisplayAmount} ${boostPerson} ${boostNumerology} ${boostSplitPercentage} + ${boostDisplayAmount} ${boostPerson} ${boostNumerology} ${boostSplitPercentage} ${boostWalletInfo}
${boostPodcastEpisode} diff --git a/webroot/template/general-settings.hbs b/webroot/template/general-settings.hbs index 8fc8bd1..bcdb767 100644 --- a/webroot/template/general-settings.hbs +++ b/webroot/template/general-settings.hbs @@ -29,6 +29,10 @@ +
+ + +