Skip to content

Commit dc90027

Browse files
authored
feat: Auto-switch to Search tab when query parameters are present in URL (resolves #331). (#364)
1 parent 3abe4cc commit dc90027

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/components/AppController.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import React, {
55

66
import useLogFileStore from "../stores/logFileStore";
77
import useQueryStore from "../stores/queryStore";
8+
import useUiStore from "../stores/uiStore";
89
import useViewStore from "../stores/viewStore";
10+
import {TAB_NAME} from "../typings/tab";
911
import {HASH_PARAM_NAMES} from "../typings/url";
1012
import {
1113
CURSOR_CODE,
@@ -30,6 +32,8 @@ import {
3032
const handleHashChange = () => {
3133
updateViewHashParams();
3234
if (updateQueryHashParams()) {
35+
const {setActiveTabName} = useUiStore.getState();
36+
setActiveTabName(TAB_NAME.SEARCH);
3337
const {startQuery} = useQueryStore.getState();
3438
startQuery();
3539
}

src/stores/logFileStore.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const handleQueryResults = (progress: number, results: QueryResults) => {
110110
};
111111

112112

113+
// eslint-disable-next-line max-lines-per-function
113114
const useLogFileStore = create<LogFileState>((set) => ({
114115
...LOG_FILE_STORE_DEFAULT,
115116
loadFile: (fileSrc: FileSrcType, cursor: CursorType) => {
@@ -166,6 +167,8 @@ const useLogFileStore = create<LogFileState>((set) => ({
166167
setUiState(UI_STATE.READY);
167168

168169
if (updateQueryHashParams()) {
170+
const {setActiveTabName} = useUiStore.getState();
171+
setActiveTabName(TAB_NAME.SEARCH);
169172
const {startQuery} = useQueryStore.getState();
170173
startQuery();
171174
}

0 commit comments

Comments
 (0)