mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
Fix multi-path distance summing
This commit is contained in:
@@ -549,7 +549,7 @@ async def _migrate_008_convert_path_to_paths_array(conn: aiosqlite.Connection) -
|
||||
cursor = await conn.execute(
|
||||
"SELECT id, path, received_at FROM messages WHERE path IS NOT NULL AND paths IS NULL"
|
||||
)
|
||||
rows = await cursor.fetchall()
|
||||
rows = list(await cursor.fetchall())
|
||||
|
||||
if rows:
|
||||
logger.info("Converting %d messages from path to paths array format...", len(rows))
|
||||
|
||||
1
frontend/dist/assets/index-BOYNFe5S.js.map
vendored
1
frontend/dist/assets/index-BOYNFe5S.js.map
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
frontend/dist/assets/index-C-0BydkT.js.map
vendored
Normal file
1
frontend/dist/assets/index-C-0BydkT.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/dist/assets/index-CObwAA2o.css
vendored
1
frontend/dist/assets/index-CObwAA2o.css
vendored
File diff suppressed because one or more lines are too long
1
frontend/dist/assets/index-CcSjAzwK.css
vendored
Normal file
1
frontend/dist/assets/index-CcSjAzwK.css
vendored
Normal file
File diff suppressed because one or more lines are too long
4
frontend/dist/index.html
vendored
4
frontend/dist/index.html
vendored
@@ -13,8 +13,8 @@
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
<script type="module" crossorigin src="/assets/index-BOYNFe5S.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CObwAA2o.css">
|
||||
<script type="module" crossorigin src="/assets/index-C-0BydkT.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CcSjAzwK.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -67,9 +67,41 @@ export function PathModal({ open, onClose, paths, senderInfo, contacts, config }
|
||||
Path {index + 1} — received {formatTime(pathData.received_at)}
|
||||
</div>
|
||||
)}
|
||||
<PathVisualization resolved={pathData.resolved} senderInfo={senderInfo} />
|
||||
<PathVisualization
|
||||
resolved={pathData.resolved}
|
||||
senderInfo={senderInfo}
|
||||
hideStraightLine={!hasSinglePath}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Straight-line distance shown once for multi-path (same for all routes) */}
|
||||
{!hasSinglePath &&
|
||||
resolvedPaths.length > 0 &&
|
||||
(() => {
|
||||
const first = resolvedPaths[0].resolved;
|
||||
if (
|
||||
isValidLocation(first.sender.lat, first.sender.lon) &&
|
||||
isValidLocation(first.receiver.lat, first.receiver.lon)
|
||||
) {
|
||||
return (
|
||||
<div className="pt-3 mt-1 border-t border-border">
|
||||
<span className="text-sm text-muted-foreground">Straight-line distance: </span>
|
||||
<span className="text-sm font-medium">
|
||||
{formatDistance(
|
||||
calculateDistance(
|
||||
first.sender.lat,
|
||||
first.sender.lon,
|
||||
first.receiver.lat,
|
||||
first.receiver.lon
|
||||
)!
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
})()}
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
@@ -83,9 +115,11 @@ export function PathModal({ open, onClose, paths, senderInfo, contacts, config }
|
||||
interface PathVisualizationProps {
|
||||
resolved: ResolvedPath;
|
||||
senderInfo: SenderInfo;
|
||||
/** If true, hide the straight-line distance (shown once at container level for multi-path) */
|
||||
hideStraightLine?: boolean;
|
||||
}
|
||||
|
||||
function PathVisualization({ resolved, senderInfo }: PathVisualizationProps) {
|
||||
function PathVisualization({ resolved, senderInfo, hideStraightLine }: PathVisualizationProps) {
|
||||
// Track previous location for each hop to calculate distances
|
||||
// Returns null if previous hop was ambiguous or has invalid location
|
||||
const getPrevLocation = (hopIndex: number): { lat: number | null; lon: number | null } | null => {
|
||||
@@ -162,7 +196,8 @@ function PathVisualization({ resolved, senderInfo }: PathVisualizationProps) {
|
||||
)}
|
||||
|
||||
{/* Straight-line distance (when both sender and receiver have coordinates) */}
|
||||
{isValidLocation(resolved.sender.lat, resolved.sender.lon) &&
|
||||
{!hideStraightLine &&
|
||||
isValidLocation(resolved.sender.lat, resolved.sender.lon) &&
|
||||
isValidLocation(resolved.receiver.lat, resolved.receiver.lon) && (
|
||||
<div
|
||||
className={
|
||||
|
||||
Reference in New Issue
Block a user