Forum teuk.org

mbweb β€” Bug fixes and improvements round 4 (April 2026)

in Mediabot Β· started by TeuK Β· 15h ago

TeuK Β· 15h ago

mbweb β€” Bug fixes and improvements round 4 (April 2026)

Context

Fourth pass on the mbweb web console. Snap 20260429-1009 analysed and cleaned. Bugs, dead code, remaining French strings, and the last open improvement items from the backlog.


Bug fixes

B1 β€” Users stat card showing page count instead of total

The β€œTotal” card on /users was displaying users.length (number of rows on the current page, max 50) instead of total (the global count from the DB). Fixed to use total.

B2 β€” /api/dashboard missing try/catch

The dashboard API endpoint was the only API route without error handling. A getDashboardData failure would propagate as an unhandled rejection and return HTML instead of JSON. Wrapped in try/catch consistent with all other API routes.

B3 β€” Empty <div> parasite in /channels table section

An empty <div></div> was inserted between the pagination bar and the channel table, producing unexpected whitespace in the layout. Removed.


Remaining French strings

Five strings were still in French across four route files:

  • routes/api.js β€” three inline comments
  • routes/home.js β€” section title and subtitle in quickActions
  • routes/profile.js β€” stat card label in accessible channels
  • routes/quotes.js β€” stat card label for channels with quotes
  • routes/commands.js β€” count badge label

All translated to English. Zero French strings remaining in the codebase.


R1 β€” Dead imports removed from routes/home.js

After the app.js split, home.js retained the full import block from the original monolith: 15 functions from mediabotRepository, of which 0 were actually called in that file. home.js delegates all data fetching to getDashboardData and never touches the repository directly. The entire import block was removed.


A2 β€” Search/filter on /channels

Master and above can now filter the channel list by name, description or topic via a ?q= search bar. The filter is applied server-side via a LIKE query in getAllChannels. Pagination preserves the active search term between pages. Non-Master users are not shown the filter bar (they already see only their own channels; free-text search adds no value there).

/api/channels also accepts ?q= and returns search in the JSON response.


A3 β€” Short-term cache for getUserChannels in dashboardData.js

getDashboardData called getUserChannels on every home page load. On authenticated pages, requireLogin can also trigger refreshSessionUser which calls getUserChannels for the same user within the same request window.

A 30-second in-memory cache keyed by id_user was added in dashboardData.js. If the home page is loaded within 30 seconds of any other authenticated page load, the DB is not hit a second time. Expired entries are evicted lazily to prevent unbounded growth.


A1 β€” CSS classes verified

All pagination and filter bar CSS classes introduced in previous rounds (.mbw-pagination, .mbw-page-btn, .mbw-filter-bar, .mbw-search-input, .mbw-select) were confirmed present in public/css/mbweb.css with correct definitions including hover and disabled states.


Status after round 4

# Item Status
B1 Users stat card users.length β†’ total βœ… fixed
B2 /api/dashboard missing try/catch βœ… fixed
B3 Empty <div> in channels table βœ… fixed
i18n Last French strings (5) βœ… done
R1 15 dead imports in home.js βœ… removed
A1 CSS classes verified βœ… ok
A2 Search/filter on /channels βœ… done
A3 Cache getUserChannels in dashboardData βœ… done

No open items remaining from the audit backlog. Long-term: EJS migration (R12), Matrix/Discord stubs.

You must be logged in to reply.