Skip to content

Commit

Permalink
Add setting to toggle showing of hosted wallet ids
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpp committed Dec 12, 2024
1 parent 6d4b9e9 commit a38fcb6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
19 changes: 15 additions & 4 deletions dbif/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub struct SettingsRecord {
pub play_pew: bool,
pub custom_pew_file: Option<String>,
pub resolve_nostr_refs: bool,
pub show_hosted_wallet_ids: bool,
}

#[derive(Debug, Default, Clone)]
Expand Down Expand Up @@ -384,6 +385,10 @@ pub fn create_database(filepath: &String) -> Result<bool, Box<dyn Error>> {
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 (
Expand Down Expand Up @@ -1293,7 +1298,8 @@ pub fn load_settings_from_db(filepath: &String) -> Result<SettingsRecord, Box<dy
hide_boosts_below,
play_pew,
custom_pew_file,
resolve_nostr_refs
resolve_nostr_refs,
show_hosted_wallet_ids
FROM
settings
WHERE
Expand All @@ -1310,6 +1316,7 @@ pub fn load_settings_from_db(filepath: &String) -> Result<SettingsRecord, Box<dy
play_pew: row.get(4)?,
custom_pew_file: row.get(5).ok(),
resolve_nostr_refs: row.get(6)?,
show_hosted_wallet_ids: row.get(7)?,
})
});

Expand All @@ -1323,6 +1330,7 @@ pub fn load_settings_from_db(filepath: &String) -> Result<SettingsRecord, Box<dy
play_pew: true,
custom_pew_file: None,
resolve_nostr_refs: false,
show_hosted_wallet_ids: false,
}),
Err(e) => Err(Box::new(e)),
}
Expand All @@ -1340,18 +1348,20 @@ 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,
hide_boosts = excluded.hide_boosts,
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,
Expand All @@ -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(_) => {
Expand Down
2 changes: 2 additions & 0 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ pub struct GeneralSettingsMultipart {
hide_boosts_below: Option<String>,
play_pew: Option<bool>,
resolve_nostr_refs: Option<bool>,
show_hosted_wallet_ids: Option<bool>,

// 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
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion webroot/script/helipad.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -178,6 +179,11 @@ $(document).ready(function () {
}
}

let boostWalletInfo = '';
if (settings.show_hosted_wallet_ids && boostCustomValue) {
boostWalletInfo = `<small>[Wallet #${escapeHTML(boostCustomValue)}]</small>`;
}

//Show clock icon for automated boosts
if (boostTlv && boostTlv.action == "auto") {
boostDisplayAmount = `
Expand Down Expand Up @@ -236,7 +242,7 @@ $(document).ready(function () {
</div>
</div>
<h5 class="sats">
${boostDisplayAmount} ${boostPerson} ${boostNumerology} ${boostSplitPercentage}
${boostDisplayAmount} ${boostPerson} ${boostNumerology} ${boostSplitPercentage} ${boostWalletInfo}
</h5>
<small class="podcast_episode">
${boostPodcastEpisode}
Expand Down
4 changes: 4 additions & 0 deletions webroot/template/general-settings.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<input class="form-check-input" type="checkbox" id="resolve-nostr-refs" name="resolve_nostr_refs" value="true"{{#if settings.resolve_nostr_refs}} checked{{/if}}>
<label class="form-check-label" for="resolve-nostr-refs" style="user-select: none">Resolve Nostr npub references to names</label>
</div>
<div class="form-check mt-2">
<input class="form-check-input" type="checkbox" id="show-hosted-wallet-ids" name="show_hosted_wallet_ids" value="true"{{#if settings.show_hosted_wallet_ids}} checked{{/if}}>
<label class="form-check-label" for="show-hosted-wallet-ids" style="user-select: none">Show IDs for wallets hosted on your node</label>
</div>
</div>

<div class="form-group">
Expand Down

0 comments on commit a38fcb6

Please sign in to comment.