Skip to content

Commit

Permalink
get config from server
Browse files Browse the repository at this point in the history
  • Loading branch information
findus committed Nov 12, 2024
1 parent c18d7df commit e7b9739
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions web/src/components/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ import {
onMounted,
onBeforeUnmount,
watch,
onBeforeMount,
reactive,
} from "vue";
import { useRoute, useRouter } from "vue-router/composables";
import { useRootStore } from "@/stores";
import { tagNameForURI } from "@/filters";
import { VTextField } from "vuetify/lib";
import { isClientConfig } from "@/apiClient.guard";
const store = useRootStore();
const route = useRoute();
Expand Down Expand Up @@ -188,10 +191,12 @@ const searchBoxFieldRect = computed(() => {
EventBus.on("setSearchTerm", setSearchTerm);
const reactiveStore = reactive(store);
watch(
[route,searchBoxFieldRect],
[route,searchBoxField,reactiveStore],
() => {
if (!route.query.q) {
if (route && searchBoxField && reactiveStore.clientConfig && !route.query.q) {
var input = searchBoxField.value?.$el.querySelector("input");
setSearchBox(" ltime:-1h:");
input?.focus();
Expand Down Expand Up @@ -230,13 +235,16 @@ watch(
{ immediate: true },
);
onMounted(() => {
onBeforeMount(() => {
store.getClientConfig().catch((err: string) => {
EventBus.emit("showError", `Failed to get clientconfig: ${err}`);
EventBus.emit("showError", `Failed to update converters: ${err}`);
});
store.updateConverters().catch((err: string) => {
EventBus.emit("showError", `Failed to update converters: ${err}`);
});
});
onMounted(() => {
const keyListener = (e: KeyboardEvent) => {
if (e.target === null || !(e.target instanceof Element)) return;
if (["input", "textarea"].includes(e.target.tagName.toLowerCase())) return;
Expand Down

0 comments on commit e7b9739

Please sign in to comment.