mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-07 01:03:34 +02:00
Add database-level payload dedupe
This commit is contained in:
@@ -4,7 +4,6 @@ import type {
|
||||
Channel,
|
||||
CommandResponse,
|
||||
Contact,
|
||||
DedupResult,
|
||||
HealthStatus,
|
||||
MaintenanceResult,
|
||||
Message,
|
||||
@@ -169,7 +168,6 @@ export const api = {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ prune_undecrypted_days: pruneUndecryptedDays }),
|
||||
}),
|
||||
deduplicatePackets: () => fetchJson<DedupResult>('/packets/dedup', { method: 'POST' }),
|
||||
|
||||
// Read State
|
||||
markAllRead: () =>
|
||||
|
||||
@@ -22,7 +22,6 @@ export function MaintenanceModal({
|
||||
}: MaintenanceModalProps) {
|
||||
const [retentionDays, setRetentionDays] = useState('14');
|
||||
const [cleaning, setCleaning] = useState(false);
|
||||
const [deduping, setDeduping] = useState(false);
|
||||
|
||||
const handleCleanup = async () => {
|
||||
const days = parseInt(retentionDays, 10);
|
||||
@@ -52,30 +51,6 @@ export function MaintenanceModal({
|
||||
}
|
||||
};
|
||||
|
||||
const handleDedup = async () => {
|
||||
setDeduping(true);
|
||||
|
||||
try {
|
||||
const result = await api.deduplicatePackets();
|
||||
if (result.started) {
|
||||
toast.success('Deduplication started', {
|
||||
description: result.message,
|
||||
});
|
||||
} else {
|
||||
toast.info('Deduplication', {
|
||||
description: result.message,
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to start deduplication:', err);
|
||||
toast.error('Deduplication failed', {
|
||||
description: err instanceof Error ? err.message : 'Unknown error',
|
||||
});
|
||||
} finally {
|
||||
setDeduping(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(isOpen) => !isOpen && onClose()}>
|
||||
<DialogContent className="sm:max-w-[400px]">
|
||||
@@ -115,17 +90,6 @@ export function MaintenanceModal({
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<Label>Remove Duplicate Packets</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Remove packets with duplicate payloads (same message received via different paths).
|
||||
Runs in background and may take a long time.
|
||||
</p>
|
||||
<Button variant="outline" onClick={handleDedup} disabled={deduping}>
|
||||
{deduping ? 'Starting...' : 'Remove Duplicates'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -49,12 +49,6 @@ export interface MaintenanceResult {
|
||||
vacuumed: boolean;
|
||||
}
|
||||
|
||||
export interface DedupResult {
|
||||
started: boolean;
|
||||
total_packets: number;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface Contact {
|
||||
public_key: PublicKey;
|
||||
name: string | null;
|
||||
|
||||
Reference in New Issue
Block a user