mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-29 02:22:09 +08:00
gaslight
This commit is contained in:
@@ -388,6 +388,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"AMapKey1", {PERSISTENT | DONT_LOG, STRING, "", "", 0}},
|
||||
{"AMapKey2", {PERSISTENT | DONT_LOG, STRING, "", "", 0}},
|
||||
{"ApiCache_NavDestinations", {PERSISTENT, JSON, "[]", "[]"}},
|
||||
{"FavoriteDestinations", {PERSISTENT, JSON, "[]", "[]"}},
|
||||
{"MapAcceleration", {PERSISTENT, BOOL, "0", "0", 1}},
|
||||
{"MapboxPublicKey", {PERSISTENT | DONT_LOG, STRING, "", "", 0}},
|
||||
{"MapBoxRequests", {PERSISTENT, JSON, "{}", "{}"}},
|
||||
|
||||
@@ -151,6 +151,7 @@ export function NavDestination() {
|
||||
confirmedRoute: null,
|
||||
confirmedRouteRefresh: 0,
|
||||
destination: undefined,
|
||||
favoriteRoutes: [],
|
||||
favoriteToRemove: null,
|
||||
favoriteToRename: null,
|
||||
favoritesCount: 0,
|
||||
@@ -370,7 +371,12 @@ export function NavDestination() {
|
||||
}
|
||||
|
||||
function isRouteFavorited(route, favorites) {
|
||||
return favorites.some(fav =>
|
||||
if (!route || !Array.isArray(route.destinationCoordinates) || route.destinationCoordinates.length !== 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const favoriteRoutes = Array.isArray(favorites) ? favorites : [];
|
||||
return favoriteRoutes.some(fav =>
|
||||
fav.latitude === route.destinationCoordinates[1] &&
|
||||
fav.longitude === route.destinationCoordinates[0]
|
||||
);
|
||||
@@ -413,8 +419,13 @@ export function NavDestination() {
|
||||
async function loadFavoritesAlphabetically() {
|
||||
try {
|
||||
const res = await fetch("/api/navigation/favorite");
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to load favorites: ${res.status}`);
|
||||
}
|
||||
|
||||
const json = await res.json();
|
||||
const sorted = json.favorites.sort((a, b) => (a.name || "").localeCompare(b.name || ""));
|
||||
const favorites = Array.isArray(json?.favorites) ? [...json.favorites] : [];
|
||||
const sorted = favorites.sort((a, b) => (a.name || "").localeCompare(b.name || ""));
|
||||
state.favoritesCount = sorted.length;
|
||||
state.favoriteRoutes = sorted;
|
||||
addFavoriteMarkers(sorted);
|
||||
@@ -834,6 +845,11 @@ function NavigationDestination({
|
||||
routeId
|
||||
})
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to add favorite: ${res.status}`);
|
||||
}
|
||||
|
||||
const { message } = await res.json();
|
||||
showSnackbar(message || "Added to favorites!");
|
||||
await loadFavorites();
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Home } from "/assets/components/home/home.js"
|
||||
import { LateralManeuvers } from "/assets/components/tools/lateral_maneuvers.js"
|
||||
import { LongitudinalManeuvers } from "/assets/components/tools/longitudinal_maneuvers.js"
|
||||
import { MapsManager } from "/assets/components/tools/maps.js"
|
||||
import { NavDestination } from "/assets/components/navigation/navigation_destination.js"
|
||||
import { NavDestination } from "/assets/components/navigation/navigation_destination.js?v=nav-favorites-1"
|
||||
import { NavKeys } from "/assets/components/navigation/navigation_keys.js"
|
||||
import { RouteRecordings } from "/assets/components/recordings/dashcam_routes.js"
|
||||
import { SettingsView } from "/assets/components/settings.js"
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<link rel="stylesheet" href="/assets/components/home/home.css">
|
||||
<link rel="stylesheet" href="/assets/components/main.css">
|
||||
<link rel="stylesheet" href="/assets/components/modal.css">
|
||||
<link rel="stylesheet" href="/assets/components/navigation/navigation_destination.css">
|
||||
<link rel="stylesheet" href="/assets/components/navigation/navigation_destination.css?v=nav-favorites-1">
|
||||
<link rel="stylesheet" href="/assets/components/navigation/navigation_keys.css">
|
||||
<link rel="stylesheet" href="/assets/components/recordings/dashcam_routes.css">
|
||||
<link rel="stylesheet" href="/assets/components/recordings/screen_recordings.css">
|
||||
|
||||
Reference in New Issue
Block a user