add close button in modals & add app details page

This commit is contained in:
Bekbolsun
2024-01-29 21:10:11 +06:00
parent 5fa22a2d9e
commit 3fa6e1cdaa
32 changed files with 474 additions and 75 deletions

View File

@@ -0,0 +1,41 @@
import { nip19 } from 'nostr-tools'
import { NIP46_RELAYS } from '../consts'
export async function log(s: string) {
const log = document.getElementById('log')
if (log) log.innerHTML = s
}
export async function call(cb: () => any) {
try {
return await cb()
} catch (e) {
console.log(`Error: ${e}`)
}
}
export const getShortenNpub = (npub = '') => {
return npub.substring(0, 10) + '...' + npub.slice(-6)
}
export const getBunkerLink = (npub = '') => {
if (!npub) return ''
const { data: pubkey } = nip19.decode(npub)
return `bunker://${pubkey}?relay=${NIP46_RELAYS[0]}`
}
export async function askNotificationPermission() {
return new Promise<void>((ok, rej) => {
// Let's check if the browser supports notifications
if (!('Notification' in window)) {
log('This browser does not support notifications.')
rej()
} else {
Notification.requestPermission().then(() => {
log('notifications perm' + Notification.permission)
if (Notification.permission === 'granted') ok()
else rej()
})
}
})
}