diff --git a/web_src/js/components/DiffFileTree.vue b/web_src/js/components/DiffFileTree.vue
index 1ead1458e9..9fc08af1fc 100644
--- a/web_src/js/components/DiffFileTree.vue
+++ b/web_src/js/components/DiffFileTree.vue
@@ -5,7 +5,7 @@
>
{{ tooManyFilesMessage }}{{ showMoreMessage }}
@@ -17,6 +17,7 @@
import DiffFileTreeItem from './DiffFileTreeItem.vue';
import {doLoadMoreFiles} from '../features/repo-diff.js';
import {toggleElem} from '../utils/dom.js';
+import {DiffTreeStore} from '../modules/stores.js';
const {pageData} = window.config;
const LOCAL_STORAGE_KEY = 'diff_file_tree_visible';
@@ -28,7 +29,7 @@ export default {
pageData.diffFileInfo.fileTreeIsVisible = fileTreeIsVisible;
return {
...pageData.diffFileInfo,
- selectedFile: ''
+ store: DiffTreeStore,
};
},
computed: {
@@ -102,10 +103,10 @@ export default {
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', this.toggleVisibility);
this.hashChangeListener = () => {
- this.selectedFile = window.location.hash;
+ this.store.selectedItem = window.location.hash;
};
- this.hashListener = window.addEventListener('hashchange', this.hashChangeListener);
- this.selectedFile = window.location.hash;
+ this.hashChangeListener();
+ window.addEventListener('hashchange', this.hashChangeListener);
},
unmounted() {
document.querySelector('.diff-toggle-file-tree-button').removeEventListener('click', this.toggleVisibility);
diff --git a/web_src/js/components/DiffFileTreeItem.vue b/web_src/js/components/DiffFileTreeItem.vue
index 9fdb78875d..baaa01b782 100644
--- a/web_src/js/components/DiffFileTreeItem.vue
+++ b/web_src/js/components/DiffFileTreeItem.vue
@@ -1,7 +1,7 @@
@@ -40,6 +40,7 @@
diff --git a/web_src/js/modules/stores.js b/web_src/js/modules/stores.js
new file mode 100644
index 0000000000..24b913ce11
--- /dev/null
+++ b/web_src/js/modules/stores.js
@@ -0,0 +1,5 @@
+import {reactive} from 'vue';
+
+export const DiffTreeStore = reactive({
+ selectedItem: '',
+});