diff --git a/starpilot/system/the_galaxy/assets/mobile/js/views/Recordings.js b/starpilot/system/the_galaxy/assets/mobile/js/views/Recordings.js index c4592fe2f7..b4312c6bee 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/views/Recordings.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/views/Recordings.js @@ -3,6 +3,7 @@ import { GalaxyConfirm } from "../components/GalaxyModal.js" import { GalaxyTabs } from "../components/GalaxyTabs.js" import { GxNotice } from "../components/GxNotice.js" import { isFirestarOrigin } from "../components/PwaInstallSection.js" +import { normalizeRoute, routeMatchesSearch, sortRoutes } from "../../../components/recordings/dashcam_routes_helpers.js" function fmtDuration(seconds) { seconds = Number(seconds) || 0 @@ -37,19 +38,9 @@ function formatScreenDate(dateString) { return `${month} ${day}${getOrdinalSuffix(day)}, ${year} - ${hour}:${minuteStr}${ampm}` } -function normalizeRoute(r) { - const name = String(r?.name || "") - const isCustomName = !!r?.isCustomName - return { - name, - displayName: r?.displayName || name.split("--").pop() || name, - displayDate: r?.displayDate || "", - approxDurationSeconds: Number(r?.approxDurationSeconds || 0), - segmentCount: Number(r?.segmentCount || r?.numSegments || 0), - is_preserved: !!r?.is_preserved, - isCustomName, - png: r?.png || "", - } +function routeIdShort(route) { + const name = String(route?.name || "") + return name.split("--").slice(1).join("--") || name } function localDeviceUrl(ip, route = "/") { @@ -101,24 +92,14 @@ export const Recordings = { } }, visibleRoutes() { - let list = this.routes.slice() - if (this.showPreservedOnly) list = list.filter((r) => r.is_preserved) - if (this.searchQuery.trim()) { - const q = this.searchQuery.toLowerCase() - list = list.filter((r) => [r.displayName, r.displayDate, r.name].some((v) => String(v || "").toLowerCase().includes(q))) - } - const sorters = { - newest: (a, b) => (b.name > a.name ? 1 : -1), - oldest: (a, b) => (a.name > b.name ? 1 : -1), - longest: (a, b) => b.approxDurationSeconds - a.approxDurationSeconds, - shortest: (a, b) => a.approxDurationSeconds - b.approxDurationSeconds, - } - return list.sort(sorters[this.sortOrder] || sorters.newest) + const list = this.routes.filter((r) => (!this.showPreservedOnly || r.is_preserved) && routeMatchesSearch(r, this.searchQuery)) + return sortRoutes(list, this.sortOrder) }, }, methods: { fmtDuration, formatBytes, + routeIdShort, setSub(key) { this.sub = key === "screen" ? "screen" : "routes" if (this.sub === "screen" && !this.recordings.length && !this.screenLoading) this.loadScreenRecordings() @@ -207,8 +188,8 @@ export const Recordings = { if (!newName || newName === route.displayName) return try { const payload = await api.renameRoute(route.name, newName) - Object.assign(route, normalizeRoute({ ...route, isCustomName: true })) - route.displayName = payload.name || newName + const savedName = payload.name || newName + Object.assign(route, normalizeRoute({ ...route, timestamp: savedName, isCustomName: true })) showSnackbar("Route renamed!") } catch (e) { showSnackbar("Rename failed.", "error") @@ -392,7 +373,7 @@ export const Recordings = { {{ stats.count }} drives · {{ stats.formattedDuration }}
- +