Manually opening a channel will check its status again

This commit is contained in:
Cadence Ember 2023-04-07 21:43:39 +12:00
parent cfa04f4a27
commit 59266a6419
1 changed files with 4 additions and 13 deletions

View File

@ -26,22 +26,13 @@ async function fetchChannel(path, ucid, instance) {
if (!instance) throw new Error("No instance parameter provided") if (!instance) throw new Error("No instance parameter provided")
const row = db.prepare("SELECT * FROM Channels WHERE ucid = ?").get(ucid) const row = db.prepare("SELECT * FROM Channels WHERE ucid = ?").get(ucid)
// can branch on row.missing if needed, but account termination is not permanent,
// handle the case where the channel has a known error // so we need to fetch new data from the web either way...
if (row && row.missing_reason) {
return {
error: true,
ucid,
row,
missing: true,
message: row.missing_reason
}
}
/** @type {any} */ /** @type {any} */
const channel = await request(`${instance}/api/v1/channels/${ucid}?second__path=${path}`).then(res => res.json()) const channel = await request(`${instance}/api/v1/channels/${ucid}?second__path=${path}`).then(res => res.json())
// handle the case where the channel has a newly discovered error // handle the case where the just-fetched channel has an error
if (channel.error) { if (channel.error) {
const missingData = updateBadData(channel) const missingData = updateBadData(channel)
return { return {
@ -52,7 +43,7 @@ async function fetchChannel(path, ucid, instance) {
} }
} }
// handle the case where the channel returns good data (this is the only remaining scenario) // handle the case where the just-fetched channel does not have an error
updateGoodData(channel) updateGoodData(channel)
return channel return channel
} }