Search: Clear earlier searches when a new one is executed

Fixes: https://github.com/thelounge/thelounge/issues/4637
This commit is contained in:
Reto Brunner 2022-11-12 23:51:07 +01:00
parent 51c9ce078d
commit 83e11b0143

View File

@ -186,9 +186,14 @@ export default defineComponent({
return new Date(previousMessage.time).getDay() !== new Date(message.time).getDay(); return new Date(previousMessage.time).getDay() !== new Date(message.time).getDay();
}; };
const doSearch = () => { const clearSearchState = () => {
offset.value = 0; offset.value = 0;
store.commit("messageSearchInProgress", true); store.commit("messageSearchInProgress", false);
store.commit("messageSearchResults", null);
};
const doSearch = () => {
clearSearchState(); // this is a new search, so we need to clear anything before that
socket.emit("search", { socket.emit("search", {
networkUuid: network.value?.uuid, networkUuid: network.value?.uuid,
channelName: channel.value?.name, channelName: channel.value?.name,
@ -296,6 +301,7 @@ export default defineComponent({
onUnmounted(() => { onUnmounted(() => {
eventbus.off("escapekey", closeSearch); eventbus.off("escapekey", closeSearch);
eventbus.off("re-search", doSearch); eventbus.off("re-search", doSearch);
clearSearchState();
}); });
return { return {