fix watchTitle

This commit is contained in:
sam 2023-12-20 17:45:01 +01:00
parent 91f3f71d8d
commit 4590b7b8aa
6 changed files with 34 additions and 47 deletions

View file

@ -13,6 +13,6 @@ export const useInstanceStore = defineStore("instance", {
},
},
getters: {
instanceName: (state) => state.instance?.title || "Akkoma",
instanceName: (state) => state.instance?.title || "vulpine-fe",
},
});

View file

@ -1,17 +0,0 @@
import { watch } from "vue";
import { useInstanceStore } from "./instance";
export default function watchTitle<T extends object | undefined>(
callback: (obj: T | undefined) => string | undefined,
obj: T | undefined = undefined,
) {
const instanceStore = useInstanceStore();
watch(
() => ({ obj, instanceName: instanceStore.instanceName }),
({ obj, instanceName }) => {
const text = callback(obj);
document.title = text ? `${text} - ${instanceName}` : instanceName;
},
{ immediate: true },
);
}