Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: send theme in share URL #100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions templates/tpos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -655,19 +655,32 @@ <h6 class="text-subtitle1 q-my-none">
new Date(obj.time * 1000),
'YYYY-MM-DD HH:mm'
)
obj.tpos = ['/tpos/', obj.id].join('')
obj.shareUrl = [
window.location.protocol,
'//',
window.location.host,
obj.tpos
].join('')
obj.tpos = `/tpos/${obj.id}`
obj.shareUrl = `${window.location.protocol}//${window.location.host}${obj.tpos}`

obj.items = JSON.parse(obj.items)
obj.itemsMap = new Map()
obj.items.forEach((item, idx) => {
let id = `${obj.id}:${idx + 1}`
obj.itemsMap.set(id, {...item, id})
})
obj.itemsMap = new Map(
obj.items.map((item, idx) => {
const id = `${obj.id}:${idx + 1}`
return [id, {...item, id}]
})
)

// Retrieve theme, dark mode, and gradient settings from localStorage.
const getSetting = key =>
localStorage.getItem(`lnbits.${key}`)?.split('|')[1] || null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use this.$q.localStorage.getItem()?
the split('|')[1] goes into the internals of quasar.

const theme = getSetting('theme')
const dark = getSetting('darkMode')
const gradient = getSetting('gradientBg')

// Append the theme, dark, and gradient settings as query parameters to the share URL.
const url = new URL(obj.shareUrl)
theme && url.searchParams.append('theme', theme)
dark && url.searchParams.append('dark', dark)
gradient && url.searchParams.append('gradient', gradient)

// Update the share URL in the object.
obj.shareUrl = url.toString()
return obj
}

Expand Down