Skip to content

Commit

Permalink
fix(snippets): persist scroll position by change view
Browse files Browse the repository at this point in the history
  • Loading branch information
antonreshetov committed Apr 19, 2022
1 parent 069e296 commit ba05384
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/renderer/App.vue
Expand Up @@ -15,7 +15,7 @@

<script setup lang="ts">
import router from '@/router'
import { ref, watch } from 'vue'
import { nextTick, ref, watch } from 'vue'
import { ipc, store, track } from './electron'
import { useAppStore } from './store/app'
import { repository } from '../../package.json'
Expand All @@ -28,6 +28,7 @@ import {
emitter
} from '@/composable'
import { createToast, destroyAllToasts } from 'vercel-toast'
import { useRoute } from 'vue-router'
// По какой то причине необходимо явно установить роут в '/'
// для корректного поведения в продакшен сборке
Expand All @@ -36,6 +37,7 @@ router.push('/')
const appStore = useAppStore()
const snippetStore = useSnippetStore()
const route = useRoute()
const isUpdateAvailable = ref(false)
Expand Down Expand Up @@ -127,6 +129,17 @@ watch(
}
)
watch(
() => route.path,
() => {
if (route.path === '/') {
nextTick(() => {
emitter.emit('scroll-to:snippet', snippetStore.selectedId!)
})
}
}
)
ipc.on('main-menu:preferences', () => {
router.push('/preferences')
})
Expand Down

0 comments on commit ba05384

Please sign in to comment.