mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
Fix up some warnings
This commit is contained in:
File diff suppressed because one or more lines are too long
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-DafoZZfC.js.map
vendored
Normal file
1
frontend/dist/assets/index-DafoZZfC.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/dist/assets/index-ei_i_-1r.js.map
vendored
1
frontend/dist/assets/index-ei_i_-1r.js.map
vendored
File diff suppressed because one or more lines are too long
2
frontend/dist/index.html
vendored
2
frontend/dist/index.html
vendored
@@ -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>
|
||||
|
||||
@@ -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