frigate plus submission fix

still show frigate+ section if snapshot has already been submitted and run optimistic update, local state was being overridden
This commit is contained in:
Josh Hawkins 2025-11-07 13:52:02 -06:00
parent 06e5852743
commit cf9a4a9407

View File

@ -1078,12 +1078,31 @@ function ObjectDetailsTab({
}); });
setState("submitted"); setState("submitted");
setSearch({ mutate(
...search, (key) =>
plus_id: "new_upload", typeof key === "string" &&
}); (key.includes("events") ||
key.includes("events/search") ||
key.includes("events/explore")),
(currentData: SearchResult[][] | SearchResult[] | undefined) => {
if (!currentData) return currentData;
// optimistic update
return currentData
.flat()
.map((event) =>
event.id === search.id
? { ...event, plus_id: "new_upload" }
: event,
);
},
{
optimisticData: true,
rollbackOnError: true,
revalidate: false,
},
);
}, },
[search, setSearch], [search, mutate],
); );
const popoverContainerRef = useRef<HTMLDivElement | null>(null); const popoverContainerRef = useRef<HTMLDivElement | null>(null);
@ -1243,7 +1262,6 @@ function ObjectDetailsTab({
</div> </div>
{search.data.type === "object" && {search.data.type === "object" &&
!search.plus_id &&
config?.plus?.enabled && config?.plus?.enabled &&
search.has_snapshot && ( search.has_snapshot && (
<div <div