From a82c5950a4c624ab8b0bb82f2bea38dd4dc861d9 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 19:45:44 +0900
Subject: [PATCH] Revert modifying scroll position in Lists
---
.../TimelineSpace/Contents/Lists/Show.vue | 62 -------------------
.../TimelineSpace/Contents/Lists/Show.ts | 12 +---
2 files changed, 3 insertions(+), 71 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue b/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
index cb7758a8..be2bc019 100644
--- a/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
@@ -13,7 +13,6 @@
v-on:delete="deleteToot"
@focusRight="focusSidebar"
@selectToot="focusToot(item)"
- @sizeChanged="sizeChanged"
>
@@ -37,7 +36,6 @@ import { Entity } from 'megalodon'
import { useStore } from '@/store'
import Toot from '@/components/organisms/Toot.vue'
import { EventEmitter } from '@/components/event'
-import { ScrollPosition } from '@/components/utils/scroll'
import { MUTATION_TYPES as CONTENTS_MUTATION } from '@/store/TimelineSpace/Contents'
import { MUTATION_TYPES as HEADER_MUTATION } from '@/store/TimelineSpace/HeaderMenu'
import { ACTION_TYPES, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Lists/Show'
@@ -55,10 +53,6 @@ export default defineComponent({
const { list_id } = toRefs(props)
const focusedId = ref(null)
- const scrollPosition = ref(null)
- const observer = ref(null)
- const scrollTime = ref(null)
- const resizeTime = ref(null)
const scroller = ref(null)
const timeline = computed(() => store.state.TimelineSpace.Contents.Lists.Show.timeline)
@@ -77,27 +71,6 @@ export default defineComponent({
load().finally(() => {
store.commit(`TimelineSpace/Contents/${CONTENTS_MUTATION.CHANGE_LOADING}`, false)
})
-
- const el = document.getElementById('scroller')
- if (el) {
- scrollPosition.value = new ScrollPosition(el)
- scrollPosition.value.prepare()
-
- observer.value = new ResizeObserver(() => {
- if (scrollPosition.value && !heading.value && !lazyLoading.value && !scrolling.value) {
- resizeTime.value = moment()
- scrollPosition.value?.restore()
- }
- })
-
- const scrollWrapper = el.getElementsByClassName('vue-recycle-scroller__item-wrapper')[0]
- observer.value?.observe(scrollWrapper)
- }
- })
- onBeforeUpdate(() => {
- if (scrollPosition.value) {
- scrollPosition.value.prepare()
- }
})
watch(list_id, () => {
store.commit(`TimelineSpace/Contents/${CONTENTS_MUTATION.CHANGE_LOADING}`, true)
@@ -135,7 +108,6 @@ export default defineComponent({
onBeforeUnmount(() => {
store.dispatch(`${space}/${ACTION_TYPES.STOP_STREAMING}`)
- observer.value?.disconnect()
})
onUnmounted(() => {
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
@@ -167,14 +139,6 @@ export default defineComponent({
return 'started'
}
const onScroll = (event: Event) => {
- if (moment().diff(resizeTime.value) < 500) {
- return
- }
- scrollTime.value = moment()
- if (!scrolling.value) {
- store.commit(`${space}/${MUTATION_TYPES.CHANGE_SCROLLING}`, true)
- }
-
if (
(event.target as HTMLElement)!.clientHeight + (event.target as HTMLElement)!.scrollTop >=
document.getElementById('scroller')!.scrollHeight - 10 &&
@@ -185,17 +149,6 @@ export default defineComponent({
list_id: list_id.value,
status: timeline.value[timeline.value.length - 1]
})
- .then(statuses => {
- if (statuses === null) {
- return
- }
- if (statuses.length > 0) {
- store.commit(`${space}/${MUTATION_TYPES.CHANGE_SCROLLING}`, true)
- setTimeout(() => {
- store.commit(`${space}/${MUTATION_TYPES.CHANGE_SCROLLING}`, false)
- }, 500)
- }
- })
.catch(() => {
ElMessage({
message: i18n.t('message.timeline_fetch_error'),
@@ -209,14 +162,6 @@ export default defineComponent({
} else if ((event.target as HTMLElement)!.scrollTop <= 10 && !heading.value) {
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
}
-
- setTimeout(() => {
- const now = moment()
- if (now.diff(scrollTime.value) >= 150) {
- scrollTime.value = null
- store.commit(`${space}/${MUTATION_TYPES.CHANGE_SCROLLING}`, false)
- }
- }, 150)
}
const reload = async () => {
store.commit(`TimelineSpace/${TIMELINE_MUTATION.CHANGE_LOADING}`, true)
@@ -268,12 +213,6 @@ export default defineComponent({
const focusSidebar = () => {
EventEmitter.emit('focus-sidebar')
}
- const sizeChanged = () => {
- store.commit(`${space}/${MUTATION_TYPES.CHANGE_SCROLLING}`, true)
- setTimeout(() => {
- store.commit(`${space}/${MUTATION_TYPES.CHANGE_SCROLLING}`, false)
- }, 500)
- }
return {
scroller,
@@ -284,7 +223,6 @@ export default defineComponent({
deleteToot,
focusSidebar,
focusToot,
- sizeChanged,
openSideBar,
heading,
upper
diff --git a/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts b/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
index 82e07204..20de51c0 100644
--- a/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
@@ -4,20 +4,18 @@ import { RootState } from '@/store'
import { LoadPositionWithList } from '@/types/loadPosition'
import { MyWindow } from '~/src/types/global'
-const win = window as any as MyWindow
+const win = (window as any) as MyWindow
export type ShowState = {
timeline: Array
lazyLoading: boolean
heading: boolean
- scrolling: boolean
}
const state = (): ShowState => ({
timeline: [],
lazyLoading: false,
- heading: true,
- scrolling: false
+ heading: true
})
export const MUTATION_TYPES = {
@@ -29,8 +27,7 @@ export const MUTATION_TYPES = {
CLEAR_TIMELINE: 'clearTimeline',
UPDATE_TOOT: 'updateToot',
DELETE_TOOT: 'deleteToot',
- CHANGE_LAZY_LOADING: 'changeLazyLoading',
- CHANGE_SCROLLING: 'changeScrolling'
+ CHANGE_LAZY_LOADING: 'changeLazyLoading'
}
const mutations: MutationTree = {
@@ -82,9 +79,6 @@ const mutations: MutationTree = {
},
[MUTATION_TYPES.CHANGE_LAZY_LOADING]: (state, value: boolean) => {
state.lazyLoading = value
- },
- [MUTATION_TYPES.CHANGE_SCROLLING]: (state, value: boolean) => {
- state.scrolling = value
}
}