@samitouri / QOSami-HFS / commits / 49408948

fix: admin/home: you could see stale warnings, even after an update

Massimo Melina committed Apr 4, 2026 at 11:29 UTC 494089483c31e3866d2ee2d31d0b868167427f57
3 files changed +16 -13
admin/src/HomePage.ts
+1 -1
@@ -66,7 +66,7 @@ export default function HomePage() {
66 return h(Box, {},
67 h(RandomPlugin),
68 h(Box, { display:'flex', gap: 2, flexDirection:'column', alignItems: 'flex-start', height: '100%' },
69 - dontBotherWithKeys(status.alerts?.map(x => entry('warning', md(x, { html: false })))),
69 + dontBotherWithKeys(status.alerts?.map(x => entry('warning', md(x, { html: false }))) || []),
70 errors.length ? dontBotherWithKeys(errors.map(msg => entry('error', dontBotherWithKeys(msg))))
71 : entry('success', "Server is working"),
72 vfs && !vfs.children?.length && !vfs.source ? entry('warning', "You have no shared files", SOLUTION_SEP, fsLink("add some")) : null,
src/adminApis.ts
+1 -1
@@ -141,7 +141,7 @@ export const adminApis = {
141 updatePossible: !await updateSupported() ? false : (await localUpdateAvailable()) ? 'local' : true,
142 previousVersionAvailable: await previousAvailable(),
143 autoCheckUpdateResult: autoCheckUpdateResult.get(), // in this form, we get the same type of the serialized json
144 - alerts: alerts.get(),
144 + alerts,
145 proxyDetected: getProxyDetected(),
146 cloudflareDetected,
147 ram: process.memoryUsage.rss(),
src/github.ts
+14 -11
@@ -22,6 +22,7 @@ import fs from 'fs'
22 import { storedMap } from './persistence'
23 import { argv } from './argv'
24 import { expiringCache } from './expiringCache'
25 +import { configReady } from './config'
26
27 const DIST_ROOT = 'dist'
28
@@ -261,7 +262,8 @@ export async function searchPlugins(text='', { skipRepos=[''] }={}) {
262 }))
263 }
264
264 -export const alerts = storedMap.singleSync<string[]>('alerts', [])
265 +export let alerts: string[] | undefined
266 +storedMap.ready().then(() => storedMap.del('alerts')) // remove legacy
267 const cachedCentralInfo = storedMap.singleSync('cachedCentralInfo', '') // persisting it could also be useful for no-internet instances, so that you can provide a fresher copy
268 export let blacklistedInstalledPlugins: string[] = []
269 // centralized hosted information, to be used as little as possible
@@ -279,19 +281,17 @@ export const getProjectInfo = debounceAsync(async () => {
281 cachedCentralInfo.set(obj)
282 obj ||= { ...cachedCentralInfo.get() || JSON.parse(builtInJson) } // fall back to built-in
283 // merge byVersions info in the main object but collect alerts separately to preserve multiple instances
282 - const allAlerts: string[] = [obj.alert]
284 + const newAlerts: string[] = [obj.alert]
285 for (const [ver, more] of Object.entries(popKey(obj, 'byVersion') || {}))
286 if (VERSION.match(new RegExp(ver))) {
285 - allAlerts.push((more as any).alert)
287 + newAlerts.push((more as any).alert)
288 Object.assign(obj, more)
289 }
288 - _.remove(allAlerts, x => !x)
289 - alerts.set(was => {
290 - if (!_.isEqual(was, allAlerts))
291 - for (const a of allAlerts)
292 - console.log("ALERT:", a)
293 - return allAlerts
294 - })
290 + _.remove(newAlerts, x => !x)
291 + if (!_.isEqual(alerts, newAlerts))
292 + for (const a of newAlerts)
293 + console.log("ALERT:", a)
294 + alerts = newAlerts
295 const black = onlyTruthy(Object.keys(obj.repo_blacklist || {}).map(findPluginByRepo))
296 blacklistedInstalledPlugins = onlyTruthy(black.map(x => _.isString(x.repo) && x.repo))
297 if (black.length) {
@@ -300,4 +300,7 @@ export const getProjectInfo = debounceAsync(async () => {
300 enablePlugin(p.id, false)
301 }
302 return obj
303 -}, { retain: HOUR, retainFailure: 60_000 })
\ No newline at end of file
303 +}, { retain: HOUR, retainFailure: 60_000 })
304 +
305 +// refresh of alerts and blacklist happens early without stalling startup
306 +configReady.then(getProjectInfo)