Skip to content

Commit ba05384

Browse files
committed
fix(snippets): persist scroll position by change view
1 parent 069e296 commit ba05384

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/renderer/App.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<script setup lang="ts">
1717
import router from '@/router'
18-
import { ref, watch } from 'vue'
18+
import { nextTick, ref, watch } from 'vue'
1919
import { ipc, store, track } from './electron'
2020
import { useAppStore } from './store/app'
2121
import { repository } from '../../package.json'
@@ -28,6 +28,7 @@ import {
2828
emitter
2929
} from '@/composable'
3030
import { createToast, destroyAllToasts } from 'vercel-toast'
31+
import { useRoute } from 'vue-router'
3132
3233
// По какой то причине необходимо явно установить роут в '/'
3334
// для корректного поведения в продакшен сборке
@@ -36,6 +37,7 @@ router.push('/')
3637
3738
const appStore = useAppStore()
3839
const snippetStore = useSnippetStore()
40+
const route = useRoute()
3941
4042
const isUpdateAvailable = ref(false)
4143
@@ -127,6 +129,17 @@ watch(
127129
}
128130
)
129131
132+
watch(
133+
() => route.path,
134+
() => {
135+
if (route.path === '/') {
136+
nextTick(() => {
137+
emitter.emit('scroll-to:snippet', snippetStore.selectedId!)
138+
})
139+
}
140+
}
141+
)
142+
130143
ipc.on('main-menu:preferences', () => {
131144
router.push('/preferences')
132145
})

0 commit comments

Comments
 (0)