This commit is contained in:
ben 2023-01-04 21:11:06 +00:00
parent a5727a0c92
commit a035612da3
4 changed files with 26 additions and 9 deletions

View file

@ -14,10 +14,10 @@ from .models import (
CreateMarket,
CreateMarketStalls,
Market,
MarketSettings,
OrderDetail,
Orders,
Products,
MarketSettings,
Stalls,
Zones,
createOrder,
@ -456,7 +456,9 @@ async def get_market_chat_by_merchant(ids: List[str]) -> List[ChatMessage]:
async def get_market_settings(user) -> Optional[MarketSettings]:
row = await db.fetchone("""SELECT * FROM market.settings WHERE "user" = ?""", (user,))
row = await db.fetchone(
"""SELECT * FROM market.settings WHERE "user" = ?""", (user,)
)
return MarketSettings(**row) if row else None

View file

@ -60,7 +60,8 @@
@click="marketDialog.show = true"
>Create Market
<q-tooltip>
Makes a simple frontend market for your stalls (not NOSTR)</q-tooltip
Makes a simple frontend market for your stalls (not
NOSTR)</q-tooltip
></q-btn
>
</q-card-section>
@ -596,7 +597,9 @@
this.$q.localStorage.set(`lnbits.market.${this.g.user.id}`, this.keys)
},
restoreKeys() {
let keys = this.$q.localStorage.getItem(`lnbits.market.${this.g.user.id}`)
let keys = this.$q.localStorage.getItem(
`lnbits.market.${this.g.user.id}`
)
if (keys) {
this.keys = keys
this.stallDialog.data.publickey = this.keys.pubkey
@ -1027,7 +1030,11 @@
////////////////////////////////////////
getMarkets() {
LNbits.api
.request('GET', '/market/api/v1/markets', this.g.user.wallets[0].inkey)
.request(
'GET',
'/market/api/v1/markets',
this.g.user.wallets[0].inkey
)
.then(response => {
if (response.data) {
this.markets = response.data.map(mapMarkets)
@ -1318,7 +1325,9 @@
} else {
ws_scheme = 'ws://'
}
ws = new WebSocket(ws_scheme + location.host + '/market/ws/' + room_name)
ws = new WebSocket(
ws_scheme + location.host + '/market/ws/' + room_name
)
ws.onmessage = async event => {
let event_data = JSON.parse(event.data)
@ -1359,7 +1368,9 @@
await this.getOrders()
this.getMarkets()
await this.getAllMessages()
let keys = this.$q.localStorage.getItem(`lnbits.market.${this.g.user.id}`)
let keys = this.$q.localStorage.getItem(
`lnbits.market.${this.g.user.id}`
)
if (keys) {
this.keys = keys
}

View file

@ -443,7 +443,9 @@
} else {
ws_scheme = 'ws://'
}
ws = new WebSocket(ws_scheme + location.host + '/market/ws/' + room_name)
ws = new WebSocket(
ws_scheme + location.host + '/market/ws/' + room_name
)
ws.onmessage = event => {
let event_data = JSON.parse(event.data)

View file

@ -422,7 +422,9 @@ async def api_market_order_shipped(
async def api_market_markets(wallet: WalletTypeInfo = Depends(get_key_type)):
# await get_market_market_stalls(market_id="FzpWnMyHQMcRppiGVua4eY")
try:
return [market.dict() for market in await get_market_markets(wallet.wallet.user)]
return [
market.dict() for market in await get_market_markets(wallet.wallet.user)
]
except:
return {"message": "We could not retrieve the markets."}