mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-02 01:51:14 +03:00
Detect active Plus model via model.plus.id instead of path prefix
This commit is contained in:
parent
61a826a309
commit
7f550e5d07
@ -66,10 +66,16 @@ type FrigatePlusModel = {
|
|||||||
const STATUS_BAR_KEY = "detectors_and_model";
|
const STATUS_BAR_KEY = "detectors_and_model";
|
||||||
|
|
||||||
const deriveInitialState = (config: FrigateConfig): PageState => {
|
const deriveInitialState = (config: FrigateConfig): PageState => {
|
||||||
|
const plusModelId = config.model?.plus?.id;
|
||||||
const modelPath = config.model?.path;
|
const modelPath = config.model?.path;
|
||||||
const plusEnabled = Boolean(config.plus?.enabled);
|
const plusEnabled = Boolean(config.plus?.enabled);
|
||||||
|
|
||||||
|
// The reliable signal that a Plus model is currently active is the
|
||||||
|
// `model.plus.id` metadata — the backend resolves `plus://...` paths to a
|
||||||
|
// local cache path at runtime, so `model.path` can't be relied on for
|
||||||
|
// detection.
|
||||||
let modelTab: ModelTab;
|
let modelTab: ModelTab;
|
||||||
if (typeof modelPath === "string" && modelPath.startsWith("plus://")) {
|
if (plusModelId) {
|
||||||
modelTab = "plus";
|
modelTab = "plus";
|
||||||
} else if (typeof modelPath === "string" && modelPath.length > 0) {
|
} else if (typeof modelPath === "string" && modelPath.length > 0) {
|
||||||
modelTab = "custom";
|
modelTab = "custom";
|
||||||
@ -78,22 +84,19 @@ const deriveInitialState = (config: FrigateConfig): PageState => {
|
|||||||
} else {
|
} else {
|
||||||
modelTab = "custom";
|
modelTab = "custom";
|
||||||
}
|
}
|
||||||
// Fallback: if Plus is not enabled, prefer Custom regardless of saved path
|
// Fallback: if Plus is not enabled, prefer Custom regardless of saved state
|
||||||
if (!plusEnabled && modelTab === "plus") {
|
if (!plusEnabled && modelTab === "plus") {
|
||||||
modelTab = "custom";
|
modelTab = "custom";
|
||||||
}
|
}
|
||||||
|
|
||||||
const plusModelId = config.model?.plus?.id;
|
|
||||||
const { plus: _plus, ...modelWithoutPlus } = (config.model ?? {}) as Record<
|
const { plus: _plus, ...modelWithoutPlus } = (config.model ?? {}) as Record<
|
||||||
string,
|
string,
|
||||||
unknown
|
unknown
|
||||||
>;
|
>;
|
||||||
// Don't carry a Plus path into the Custom tab — it would silently re-save
|
// If a Plus model is active, the resolved `model.path` is auto-derived from
|
||||||
// the same Plus model when the user thinks they switched modes.
|
// `plus.id` — drop it so the Custom tab starts clean and doesn't silently
|
||||||
if (
|
// re-save the same Plus model when the user thinks they switched modes.
|
||||||
typeof modelWithoutPlus.path === "string" &&
|
if (plusModelId) {
|
||||||
modelWithoutPlus.path.startsWith("plus://")
|
|
||||||
) {
|
|
||||||
delete modelWithoutPlus.path;
|
delete modelWithoutPlus.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user