Skip to content

Commit

Permalink
telegram fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalsim committed Aug 18, 2024
1 parent 3e293ab commit 200a7ac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/zap-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ async function generateInvoiceClick({
log("zapRequestEvent", zapRequestEvent);

const zapEndpoint = lnurlData.callback;
const recipient = lnurlData.nostrPubkey;
const receiptAuthor = lnurlData.nostrPubkey;

const url = `${zapEndpoint}?amount=${milliSats}&nostr=${encodeURIComponent(
JSON.stringify(zapRequestEvent),
Expand All @@ -345,7 +345,7 @@ async function generateInvoiceClick({
const zapReceiptEvent = await getZapReceipt({
relays,
filter: {
authors: [recipient],
authors: [receiptAuthor],
kinds: [9735],
"#p": [metadataEvent.pubkey],
since: zapRequestEvent.created_at - 20,
Expand Down
2 changes: 1 addition & 1 deletion src/telegram-web/bio.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.n-bio-zap-button {
.n-bio-zap-button, .n-bio-zap-button:hover {
color: white;
background-color: rgb(130, 80, 223);
border: solid 3px black;
Expand Down
30 changes: 23 additions & 7 deletions src/telegram-web/bio.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ async function telegramBio() {

const log = logger({ ...settings.debug, namespace: "[N][Telegram-Web]" });

const tipButtonId = "n-telegram-web-tip-button";

let existingTipButton = gui.gebid(tipButtonId);

if (existingTipButton) {
log("zap button already there");

return;
}

const ce = document.querySelector(".ChatExtra");

let username;
Expand Down Expand Up @@ -44,17 +54,14 @@ async function telegramBio() {
}
});

if (!bio) {
log(`bio is not defined for user: ${username}`);
if (!username) {
log("username is not defined");

return;
}

const tipButtonId = "n-telegram-web-tip-button";
const existingTipButton = gui.gebid(tipButtonId);

if (existingTipButton) {
log("zap button already there");
if (!bio) {
log(`bio is not defined for user: ${username}`);

return;
}
Expand Down Expand Up @@ -139,6 +146,15 @@ async function telegramBio() {
},
});

existingTipButton = gui.gebid(tipButtonId);

if (existingTipButton) {
log("zap button already there");

return;
}

log("putting zap button to dom");
gui.prepend(usernameDom, tipButton);
}

Expand Down

0 comments on commit 200a7ac

Please sign in to comment.