Skip to content

Commit

Permalink
FIX: server list filter
Browse files Browse the repository at this point in the history
  • Loading branch information
daverolo committed Mar 19, 2024
1 parent e2fc031 commit d819a8a
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,31 @@ import ServerRow from "./ServerRow.vue";
import ControlService from "@/store/ControlService";
import { useServers } from "@/store/servers";
import { useControlStore } from "@/store/theControl";
import { onMounted, watch, ref, computed } from "vue";
import { onMounted, watch, ref } from "vue";
const emit = defineEmits(["selectServer", "serverLogin", "quickLogin"]);
const serverStore = useServers();
const controlStore = useControlStore();
const searchQuery = ref("");
const searchInputRef = ref(null);
const filteredServers = ref(null);
const filteredServers = computed(() => {
const getFilteredServers = () => {
if (!searchQuery.value) {
return serverStore.savedServers?.savedConnections;
}
return serverStore.savedServers.savedConnections.filter((server) =>
server.name.toLowerCase().includes(searchQuery.value.toLowerCase())
);
};
// Recompute filteredServers when searchQuery changes
watch(searchQuery, () => {
filteredServers.value = null;
setTimeout(() => {
filteredServers.value = getFilteredServers();
}, 10);
});
watch(
Expand All @@ -101,6 +110,7 @@ onMounted(async () => {
if (searchInputRef.value) {
searchInputRef.value.focus();
}
filteredServers.value = getFilteredServers();
});
//Methods
Expand Down

0 comments on commit d819a8a

Please sign in to comment.