feat(log): ui-flow guild select and IPC warn logging
Depend on pearcord-log; log select-guild and unhandled IPC via hooks.log. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const b4a = require('b4a')
|
||||
const { createLogger } = require('pearcord-log')
|
||||
const { USER_STATUS } = require('pearcord-platform')
|
||||
|
||||
const flowLog = createLogger('ui-flow')
|
||||
|
||||
function fromBase64 (str) {
|
||||
if (typeof Buffer !== 'undefined') return Buffer.from(str || '', 'base64')
|
||||
return b4a.from(str || '', 'base64')
|
||||
@@ -27,8 +30,12 @@ function normalizeEmojiImage (image) {
|
||||
async function dispatchUiMessage (platform, msg, hooks = {}) {
|
||||
const send = hooks.send || (() => {})
|
||||
const pushState = hooks.pushState || (() => {})
|
||||
const log = hooks.log || flowLog
|
||||
const t = msg?.type
|
||||
if (!t) return false
|
||||
if (!t) {
|
||||
log.warn('ipc missing type', { keys: msg ? Object.keys(msg) : [] })
|
||||
return false
|
||||
}
|
||||
|
||||
if (t === 'register') {
|
||||
await platform.registerUser({
|
||||
@@ -432,6 +439,7 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
|
||||
return true
|
||||
}
|
||||
if (t === 'select-guild') {
|
||||
log.info('select-guild', { guildId: msg.guildId })
|
||||
await platform.loadGuild(msg.guildId)
|
||||
pushState()
|
||||
return true
|
||||
@@ -1260,6 +1268,7 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
|
||||
return true
|
||||
}
|
||||
|
||||
log.warn('unhandled ipc', { type: t })
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"dependencies": {
|
||||
"b4a": "^1.6.7",
|
||||
"pearcord-platform": "git+https://git.ssh.surf/pearcord/pearcord-platform.git#main",
|
||||
"pearcord-log": "file:../pearcord-log",
|
||||
"pearcord-qr": "file:../pearcord-qr"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user