mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-09 23:05:10 +02:00
Fix up some warnings
This commit is contained in:
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+20
-20
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -13,7 +13,7 @@
|
||||
<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-ei_i_-1r.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DafoZZfC.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DJA5wYVF.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
+25
-19
@@ -518,29 +518,35 @@ export function App() {
|
||||
}, []);
|
||||
|
||||
// Toggle favorite status for a conversation (via API) with optimistic update
|
||||
const handleToggleFavorite = useCallback(
|
||||
async (type: 'channel' | 'contact', id: string) => {
|
||||
// Compute optimistic new state
|
||||
const wasFavorited = isFavorite(favorites, type, id);
|
||||
const handleToggleFavorite = useCallback(async (type: 'channel' | 'contact', id: string) => {
|
||||
// Read current favorites inside the callback to avoid a dependency on the
|
||||
// derived `favorites` array (which creates a new reference every render).
|
||||
setAppSettings((prev) => {
|
||||
if (!prev) return prev;
|
||||
const currentFavorites = prev.favorites ?? [];
|
||||
const wasFavorited = isFavorite(currentFavorites, type, id);
|
||||
const optimisticFavorites = wasFavorited
|
||||
? favorites.filter((f) => !(f.type === type && f.id === id))
|
||||
: [...favorites, { type, id }];
|
||||
|
||||
// Optimistic update
|
||||
setAppSettings((prev) => (prev ? { ...prev, favorites: optimisticFavorites } : prev));
|
||||
? currentFavorites.filter((f) => !(f.type === type && f.id === id))
|
||||
: [...currentFavorites, { type, id }];
|
||||
return { ...prev, favorites: optimisticFavorites };
|
||||
});
|
||||
|
||||
try {
|
||||
const updatedSettings = await api.toggleFavorite(type, id);
|
||||
setAppSettings(updatedSettings);
|
||||
} catch (err) {
|
||||
console.error('Failed to toggle favorite:', err);
|
||||
// Revert: re-fetch would be safest, but restoring from server state on next sync
|
||||
// is acceptable. For now, just refetch settings.
|
||||
try {
|
||||
const updatedSettings = await api.toggleFavorite(type, id);
|
||||
setAppSettings(updatedSettings);
|
||||
} catch (err) {
|
||||
console.error('Failed to toggle favorite:', err);
|
||||
// Revert on error
|
||||
setAppSettings((prev) => (prev ? { ...prev, favorites } : prev));
|
||||
toast.error('Failed to update favorite');
|
||||
const settings = await api.getSettings();
|
||||
setAppSettings(settings);
|
||||
} catch {
|
||||
// If refetch also fails, leave optimistic state
|
||||
}
|
||||
},
|
||||
[favorites]
|
||||
);
|
||||
toast.error('Failed to update favorite');
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Delete channel handler
|
||||
const handleDeleteChannel = useCallback(async (key: string) => {
|
||||
|
||||
@@ -470,6 +470,7 @@ function useVisualizerData({
|
||||
return () => {
|
||||
sim.stop();
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- one-time init; dimensions/charge handled by the effect below
|
||||
}, []);
|
||||
|
||||
// Update simulation forces when dimensions/charge change
|
||||
@@ -516,6 +517,7 @@ function useVisualizerData({
|
||||
});
|
||||
syncSimulation();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- syncSimulation is stable (no deps), defined below
|
||||
}, [config, dimensions]);
|
||||
|
||||
// Reset on option changes
|
||||
|
||||
Reference in New Issue
Block a user