Make pathing clearable on click

This commit is contained in:
Jack Kingsman
2026-02-28 15:33:50 -08:00
parent 7cad4a98dd
commit 365728be02
6 changed files with 279 additions and 4 deletions
+37 -2
View File
@@ -1,5 +1,6 @@
import type React from 'react';
import { toast } from './ui/sonner';
import { api } from '../api';
import { formatTime } from '../utils/messageParser';
import { isValidLocation, calculateDistance, formatDistance } from '../utils/pathUtils';
import { getMapFocusHash } from '../utils/urlHash';
@@ -87,9 +88,43 @@ export function ChatHeader({
if (contact.last_path_len === -1) {
parts.push('flood');
} else if (contact.last_path_len === 0) {
parts.push('direct');
parts.push(
<span
key="path"
className="cursor-pointer hover:text-primary hover:underline"
onClick={(e) => {
e.stopPropagation();
if (window.confirm('Reset path to flood?')) {
api.resetContactPath(contact.public_key).then(
() => toast.success('Path reset to flood'),
() => toast.error('Failed to reset path')
);
}
}}
title="Click to reset path to flood"
>
direct
</span>
);
} else if (contact.last_path_len > 0) {
parts.push(`${contact.last_path_len} hop${contact.last_path_len > 1 ? 's' : ''}`);
parts.push(
<span
key="path"
className="cursor-pointer hover:text-primary hover:underline"
onClick={(e) => {
e.stopPropagation();
if (window.confirm('Reset path to flood?')) {
api.resetContactPath(contact.public_key).then(
() => toast.success('Path reset to flood'),
() => toast.error('Failed to reset path')
);
}
}}
title="Click to reset path to flood"
>
{contact.last_path_len} hop{contact.last_path_len > 1 ? 's' : ''}
</span>
);
}
if (isValidLocation(contact.lat, contact.lon)) {
const distFromUs =
+37 -2
View File
@@ -15,6 +15,7 @@ import { Input } from './ui/input';
import { Separator } from './ui/separator';
import { RepeaterLogin } from './RepeaterLogin';
import { useRepeaterDashboard } from '../hooks/useRepeaterDashboard';
import { api } from '../api';
import { formatTime } from '../utils/messageParser';
import { isFavorite } from '../utils/favorites';
import { cn } from '@/lib/utils';
@@ -849,9 +850,43 @@ export function RepeaterDashboard({
if (contact.last_path_len === -1) {
parts.push('flood');
} else if (contact.last_path_len === 0) {
parts.push('direct');
parts.push(
<span
key="path"
className="cursor-pointer hover:text-primary hover:underline"
onClick={(e) => {
e.stopPropagation();
if (window.confirm('Reset path to flood?')) {
api.resetContactPath(contact.public_key).then(
() => toast.success('Path reset to flood'),
() => toast.error('Failed to reset path')
);
}
}}
title="Click to reset path to flood"
>
direct
</span>
);
} else if (contact.last_path_len > 0) {
parts.push(`${contact.last_path_len} hop${contact.last_path_len > 1 ? 's' : ''}`);
parts.push(
<span
key="path"
className="cursor-pointer hover:text-primary hover:underline"
onClick={(e) => {
e.stopPropagation();
if (window.confirm('Reset path to flood?')) {
api.resetContactPath(contact.public_key).then(
() => toast.success('Path reset to flood'),
() => toast.error('Failed to reset path')
);
}
}}
title="Click to reset path to flood"
>
{contact.last_path_len} hop{contact.last_path_len > 1 ? 's' : ''}
</span>
);
}
if (isValidLocation(contact.lat, contact.lon)) {
const distFromUs =