diff --git a/lnbits/extensions/satspay/crud.py b/lnbits/extensions/satspay/crud.py index a21c73f41..245e4a1a0 100644 --- a/lnbits/extensions/satspay/crud.py +++ b/lnbits/extensions/satspay/crud.py @@ -2,8 +2,6 @@ from typing import List, Optional import httpx -from loguru import logger - from lnbits.core.services import create_invoice from lnbits.core.views.api import api_payment from lnbits.helpers import urlsafe_short_hash @@ -14,7 +12,6 @@ from ..watchonly.crud import get_config, get_fresh_address from . import db from .models import Charges, CreateCharge, SatsPaySettings - ###############CHARGES########################## @@ -96,14 +93,12 @@ async def get_charges(user: str) -> List[Charges]: ) return [Charges.from_row(row) for row in rows] + async def get_settings(user: str) -> SatsPaySettings: row = await db.fetchone( """SELECT * FROM satspay.settings WHERE "user" = ?""", (user,), ) - logger.debug('Settings data') - logger.debug(row) - if row: return SatsPaySettings.from_row(row) else: @@ -158,10 +153,7 @@ async def save_settings(user: str, data: SatsPaySettings): """ UPDATE satspay.settings SET custom_css = ? WHERE user = ? """, - ( - data.custom_css, - user - ), + (data.custom_css, user), ) else: await db.execute( diff --git a/lnbits/extensions/satspay/migrations.py b/lnbits/extensions/satspay/migrations.py index ff4304512..18995438c 100644 --- a/lnbits/extensions/satspay/migrations.py +++ b/lnbits/extensions/satspay/migrations.py @@ -27,6 +27,7 @@ async def m001_initial(db): """ ) + async def m002_add_settings_table(db): """ Settings table diff --git a/lnbits/extensions/satspay/models.py b/lnbits/extensions/satspay/models.py index d5cd48955..942263574 100644 --- a/lnbits/extensions/satspay/models.py +++ b/lnbits/extensions/satspay/models.py @@ -55,9 +55,10 @@ class Charges(BaseModel): else: return False + class SatsPaySettings(BaseModel): custom_css: str = Query(None) @classmethod def from_row(cls, row: Row) -> "SatsPaySettings": - return cls(**dict(row)) \ No newline at end of file + return cls(**dict(row)) diff --git a/lnbits/extensions/satspay/templates/satspay/display.html b/lnbits/extensions/satspay/templates/satspay/display.html index 12288c809..5f9c8287d 100644 --- a/lnbits/extensions/satspay/templates/satspay/display.html +++ b/lnbits/extensions/satspay/templates/satspay/display.html @@ -289,7 +289,12 @@
- +{% endblock %} {% block styles %} + {% endblock %} {% block scripts %} @@ -302,6 +307,7 @@ mixins: [windowMixin], data() { return { + customCss: '', charge: JSON.parse('{{charge_data | tojson}}'), mempool_endpoint: '{{mempool_endpoint}}', pendingFunds: 0, @@ -327,6 +333,17 @@ } ) }, + getCustomCss: async function () { + try { + const {data} = await LNbits.api.request( + 'GET', + `/satspay/api/v1/settings/css/${this.charge.id}` + ) + this.customCss = data + } catch (error) { + LNbits.utils.notifyApiError(error) + } + }, checkBalances: async function () { if (this.charge.hasStaleBalance) return try { @@ -428,6 +445,7 @@ } }, created: async function () { + await this.getCustomCss() if (this.charge.lnbitswallet) this.payInvoice() else this.payOnchain() await this.checkBalances() diff --git a/lnbits/extensions/satspay/templates/satspay/index.html b/lnbits/extensions/satspay/templates/satspay/index.html index 944306979..65be3a9e3 100644 --- a/lnbits/extensions/satspay/templates/satspay/index.html +++ b/lnbits/extensions/satspay/templates/satspay/index.html @@ -9,10 +9,12 @@ >New charge -