optional color

This commit is contained in:
Josh Hawkins 2024-04-22 08:35:18 -05:00
parent a0eb2138f4
commit 08b3574bb9
3 changed files with 9 additions and 9 deletions

View File

@ -177,11 +177,7 @@ export default function MasksAndZones({
setAllPolygons([...(editingPolygons ?? [])]);
setHoveredPolygonIndex(null);
setUnsavedChanges(false);
addMessage(
"masks_zones",
"Restart required (masks/zones changed)",
"text-danger",
);
addMessage("masks_zones", "Restart required (masks/zones changed)");
}, [editingPolygons, setUnsavedChanges, addMessage]);
useEffect(() => {

View File

@ -153,7 +153,7 @@ export default function MotionTuner({
useEffect(() => {
if (changedValue) {
addMessage("motion_tuner", "Unsaved motion changes", "text-danger");
addMessage("motion_tuner", "Unsaved motion tuner changes");
} else {
clearMessages("motion_tuner");
}

View File

@ -9,7 +9,7 @@ import {
export type StatusMessage = {
id: string;
text: string;
color: string;
color?: string;
};
export type StatusMessagesState = {
@ -25,7 +25,7 @@ type StatusBarMessagesContextValue = {
addMessage: (
key: string,
message: string,
color: string,
color?: string,
messageId?: string,
) => string;
removeMessage: (key: string, messageId: string) => void;
@ -45,9 +45,13 @@ export function StatusBarMessagesProvider({
const addMessage = useCallback(
(key: string, message: string, color: string, messageId?: string) => {
const id = messageId || Date.now().toString();
const msgColor = color || "text-danger";
setMessagesState((prevMessages) => ({
...prevMessages,
[key]: [...(prevMessages[key] || []), { id, text: message, color }],
[key]: [
...(prevMessages[key] || []),
{ id, text: message, color: msgColor },
],
}));
return id;
},