From edbda6cd473fa9d4ad8973c3b76c9809f4376f9a Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 19:32:38 +0900
Subject: [PATCH 1/8] Revert modifying scroll position in Public
---
.../TimelineSpace/Contents/Public.vue | 82 ++-----------------
.../store/TimelineSpace/Contents/Public.ts | 10 +--
2 files changed, 7 insertions(+), 85 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Contents/Public.vue b/src/renderer/components/TimelineSpace/Contents/Public.vue
index 534c4aa9..c0d8c04c 100644
--- a/src/renderer/components/TimelineSpace/Contents/Public.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Public.vue
@@ -13,7 +13,6 @@
v-on:delete="deleteToot"
@focusRight="focusSidebar"
@selectToot="focusToot(item)"
- @sizeChanged="sizeChanged"
>
@@ -38,7 +37,6 @@ import { useRoute } from 'vue-router'
import { useStore } from '@/store'
import Toot from '@/components/organisms/Toot.vue'
import { EventEmitter } from '@/components/event'
-import { ScrollPosition } from '@/components/utils/scroll'
import useReloadable from '@/components/utils/reloadable'
import { MUTATION_TYPES as SIDE_MENU_MUTATION } from '@/store/TimelineSpace/SideMenu'
import { MUTATION_TYPES as TIMELINE_MUTATION, ACTION_TYPES as TIMELINE_ACTION } from '@/store/TimelineSpace'
@@ -58,16 +56,11 @@ export default defineComponent({
const { j, k, Ctrl_r } = useMagicKeys()
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.Public.timeline)
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.Public.lazyLoading)
const heading = computed(() => store.state.TimelineSpace.Contents.Public.heading)
- const scrolling = computed(() => store.state.TimelineSpace.Contents.Public.scrolling)
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const unreadNotification = computed(() => store.state.TimelineSpace.timelineSetting.unreadNotification)
@@ -85,30 +78,11 @@ export default defineComponent({
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 (store.state.TimelineSpace.SideMenu.unreadPublicTimeline && heading.value) {
store.commit('TimelineSpace/SideMenu/changeUnreadPublicTimeline', false)
}
- if (scrollPosition.value) {
- scrollPosition.value.prepare()
- }
})
onBeforeUnmount(() => {
if (!unreadNotification.value.public) {
@@ -116,7 +90,6 @@ export default defineComponent({
store.dispatch(`TimelineSpace/${TIMELINE_ACTION.UNBIND_PUBLIC_STREAMING}`)
}
EventEmitter.off('focus-timeline')
- observer.value?.disconnect()
})
onUnmounted(() => {
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
@@ -170,39 +143,17 @@ export default defineComponent({
store.dispatch(`TimelineSpace/${TIMELINE_ACTION.START_PUBLIC_STREAMING}`)
}
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 &&
!lazyLoading.value
) {
- store
- .dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_TIMELINE}`, 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'),
- type: 'error'
- })
+ store.dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_TIMELINE}`, timeline.value[timeline.value.length - 1]).catch(() => {
+ ElMessage({
+ message: i18n.t('message.timeline_fetch_error'),
+ type: 'error'
})
+ })
}
if ((event.target as HTMLElement)!.scrollTop > 10 && heading.value) {
@@ -210,14 +161,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)
@@ -257,12 +200,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 {
timeline,
@@ -274,7 +211,6 @@ export default defineComponent({
deleteToot,
focusSidebar,
focusToot,
- sizeChanged,
openSideBar,
heading,
upper
@@ -293,14 +229,6 @@ export default defineComponent({
height: 100%;
}
- .loading-card {
- height: 60px;
- }
-
- .loading-card:empty {
- height: 0;
- }
-
.upper {
position: fixed;
bottom: 20px;
diff --git a/src/renderer/store/TimelineSpace/Contents/Public.ts b/src/renderer/store/TimelineSpace/Contents/Public.ts
index e78f642b..8482603d 100644
--- a/src/renderer/store/TimelineSpace/Contents/Public.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Public.ts
@@ -6,14 +6,12 @@ export type PublicState = {
timeline: Array
lazyLoading: boolean
heading: boolean
- scrolling: boolean
}
const state = (): PublicState => ({
timeline: [],
lazyLoading: false,
- heading: true,
- scrolling: false
+ heading: true
})
export const MUTATION_TYPES = {
@@ -25,8 +23,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 = {
@@ -78,9 +75,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
}
}
From ae6d8d6c133e943e095070b0b3d5de85512ffbc6 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 19:35:07 +0900
Subject: [PATCH 2/8] Revert modifying scroll position in Local
---
.../TimelineSpace/Contents/Local.vue | 72 ++-----------------
.../store/TimelineSpace/Contents/Local.ts | 10 +--
2 files changed, 7 insertions(+), 75 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Contents/Local.vue b/src/renderer/components/TimelineSpace/Contents/Local.vue
index c098aa7f..2df34e9a 100644
--- a/src/renderer/components/TimelineSpace/Contents/Local.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Local.vue
@@ -13,7 +13,6 @@
v-on:delete="deleteToot"
@focusRight="focusSidebar"
@selectToot="focusToot(item)"
- @sizeChanged="sizeChanged"
>
@@ -38,7 +37,6 @@ import { useRoute } from 'vue-router'
import { useStore } from '@/store'
import Toot from '@/components/organisms/Toot.vue'
import { EventEmitter } from '@/components/event'
-import { ScrollPosition } from '@/components/utils/scroll'
import useReloadable from '@/components/utils/reloadable'
import { ACTION_TYPES, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Local'
import { MUTATION_TYPES as SIDE_MENU_MUTATION } from '@/store/TimelineSpace/SideMenu'
@@ -58,10 +56,6 @@ export default defineComponent({
const { j, k, Ctrl_r } = useMagicKeys()
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.Local.timeline)
@@ -84,30 +78,11 @@ export default defineComponent({
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 (store.state.TimelineSpace.SideMenu.unreadLocalTimeline && heading.value) {
store.commit(`TimelineSpace/SideMenu/${SIDE_MENU_MUTATION.CHANGE_UNREAD_LOCAL_TIMELINE}`, false)
}
- if (scrollPosition.value) {
- scrollPosition.value.prepare()
- }
})
onBeforeUnmount(() => {
if (!unreadNotification.value.local) {
@@ -115,7 +90,6 @@ export default defineComponent({
store.dispatch(`TimelineSpace/${TIMELINE_ACTION.UNBIND_LOCAL_STREAMING}`)
}
EventEmitter.off('focus-timeline')
- observer.value?.disconnect()
})
onUnmounted(() => {
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
@@ -169,52 +143,23 @@ export default defineComponent({
store.dispatch(`TimelineSpace/${TIMELINE_ACTION.START_LOCAL_STREAMING}`)
}
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 &&
!lazyLoading.value
) {
- store
- .dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_TIMELINE}`, 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'),
- type: 'error'
- })
+ store.dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_TIMELINE}`, timeline.value[timeline.value.length - 1]).catch(() => {
+ ElMessage({
+ message: i18n.t('message.timeline_fetch_error'),
+ type: 'error'
})
+ })
}
if ((event.target as HTMLElement)!.scrollTop > 10 && heading.value) {
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, false)
} 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)
@@ -254,12 +199,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,
@@ -270,7 +209,6 @@ export default defineComponent({
deleteToot,
focusSidebar,
focusToot,
- sizeChanged,
openSideBar,
heading,
upper
diff --git a/src/renderer/store/TimelineSpace/Contents/Local.ts b/src/renderer/store/TimelineSpace/Contents/Local.ts
index 5fc1f107..bd420a09 100644
--- a/src/renderer/store/TimelineSpace/Contents/Local.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Local.ts
@@ -6,14 +6,12 @@ export type LocalState = {
timeline: Array
lazyLoading: boolean
heading: boolean
- scrolling: boolean
}
const state = (): LocalState => ({
timeline: [],
lazyLoading: false,
- heading: true,
- scrolling: false
+ heading: true
})
export const MUTATION_TYPES = {
@@ -25,8 +23,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 = {
@@ -78,9 +75,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
}
}
From 04084ca549c1714ae1f8f71fc3bc2d21efb90d64 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 19:43:37 +0900
Subject: [PATCH 3/8] Revert modifying scroll position in DM
---
.../TimelineSpace/Contents/DirectMessages.vue | 69 ++-----------------
.../TimelineSpace/Contents/DirectMessages.ts | 8 +--
2 files changed, 7 insertions(+), 70 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Contents/DirectMessages.vue b/src/renderer/components/TimelineSpace/Contents/DirectMessages.vue
index 83df5647..a4a83517 100644
--- a/src/renderer/components/TimelineSpace/Contents/DirectMessages.vue
+++ b/src/renderer/components/TimelineSpace/Contents/DirectMessages.vue
@@ -13,7 +13,6 @@
v-on:delete="deleteToot"
@focusRight="focusSidebar"
@selectToot="focusToot(item)"
- @sizeChanged="sizeChanged"
>
@@ -39,7 +38,6 @@ import { Entity } from 'megalodon'
import useReloadable from '@/components/utils/reloadable'
import Toot from '@/components/organisms/Toot.vue'
import { EventEmitter } from '@/components/event'
-import { ScrollPosition } from '@/components/utils/scroll'
import { ACTION_TYPES, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/DirectMessages'
import { MUTATION_TYPES as SIDE_MENU_MUTATION } from '@/store/TimelineSpace/SideMenu'
import { MUTATION_TYPES as TIMELINE_MUTATION, ACTION_TYPES as TIMELINE_ACTION } from '@/store/TimelineSpace'
@@ -58,10 +56,6 @@ export default defineComponent({
const { j, k, Ctrl_r } = useMagicKeys()
const focusedId = ref(null)
- const scrollPosition = ref(null)
- const observer = ref(null)
- const resizeTime = ref(null)
- const scrollTime = ref(null)
const scroller = ref()
const timeline = computed(() => store.state.TimelineSpace.Contents.DirectMessages.timeline)
@@ -84,27 +78,11 @@ export default defineComponent({
store.commit(`TimelineSpace/Contents/${CONTENTS_ACTION.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 (store.state.TimelineSpace.SideMenu.unreadDirectMessagesTimeline && heading.value) {
store.commit(`TimelineSpace/SideMenu/${SIDE_MENU_MUTATION.CHANGE_UNREAD_DIRECT_MESSAGES_TIMELINE}`, false)
}
- if (scrollPosition.value) {
- scrollPosition.value.prepare()
- }
})
onBeforeUnmount(() => {
if (!unreadNotification.value.direct) {
@@ -158,38 +136,18 @@ export default defineComponent({
store.dispatch(`TimelineSpace/${TIMELINE_ACTION.START_DIRECT_MESSAGES_STREAMING}`)
}
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)
- }
// for lazyLoading
if (
(event.target as HTMLElement)!.clientHeight + (event.target as HTMLElement)!.scrollTop >=
document.getElementById('scroller')!.scrollHeight - 10 &&
!lazyLoading.value
) {
- store
- .dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_TIMELINE}`, 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'),
- type: 'error'
- })
+ store.dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_TIMELINE}`, timeline.value[timeline.value.length - 1]).catch(() => {
+ ElMessage({
+ message: i18n.t('message.timeline_fetch_error'),
+ type: 'error'
})
+ })
}
if ((event.target as HTMLElement)!.scrollTop > 10 && heading.value) {
@@ -197,14 +155,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 updateToot = (message: Entity.Status) => {
store.commit(`${space}/${MUTATION_TYPES.UPDATE_TOOT}`, message)
@@ -244,12 +194,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 {
timeline,
@@ -262,8 +206,7 @@ export default defineComponent({
focusToot,
openSideBar,
heading,
- upper,
- sizeChanged
+ upper
}
}
})
diff --git a/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts b/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
index ff9b684d..3a8185d6 100644
--- a/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
+++ b/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
@@ -5,14 +5,12 @@ import { RootState } from '@/store'
export type DirectMessagesState = {
lazyLoading: boolean
heading: boolean
- scrolling: boolean
timeline: Array
}
const state = (): DirectMessagesState => ({
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: []
})
@@ -25,8 +23,7 @@ export const MUTATION_TYPES = {
ARCHIVE_TIMELINE: 'archiveTimeline',
CLEAR_TIMELINE: 'clearTimeline',
UPDATE_TOOT: 'updateToot',
- DELETE_TOOT: 'deleteToot',
- CHANGE_SCROLLING: 'changeScrolling'
+ DELETE_TOOT: 'deleteToot'
}
const mutations: MutationTree = {
@@ -79,9 +76,6 @@ const mutations: MutationTree = {
return toot.id !== id
}
})
- },
- [MUTATION_TYPES.CHANGE_SCROLLING]: (state, value: boolean) => {
- state.scrolling = value
}
}
From a82c5950a4c624ab8b0bb82f2bea38dd4dc861d9 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 19:45:44 +0900
Subject: [PATCH 4/8] 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
}
}
From 279d06e4de9050dc4bc164fe6fba2451ce64437c Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 19:48:06 +0900
Subject: [PATCH 5/8] Revert modifying scroll position in Tags
---
.../TimelineSpace/Contents/Hashtag/Tag.vue | 62 -------------------
.../TimelineSpace/Contents/Hashtag/Tag.ts | 12 +---
2 files changed, 3 insertions(+), 71 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue b/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
index 677a22c5..e8af8fd6 100644
--- a/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
@@ -12,7 +12,6 @@
v-on:delete="deleteToot"
@focusRight="focusSidebar"
@selectToot="focusToot(item)"
- @sizeChanged="sizeChanged"
>
@@ -37,7 +36,6 @@ import { useRoute } from 'vue-router'
import { useStore } from '@/store'
import Toot from '@/components/organisms/Toot.vue'
import { EventEmitter } from '@/components/event'
-import { ScrollPosition } from '@/components/utils/scroll'
import useReloadable from '@/components/utils/reloadable'
import { MUTATION_TYPES as TIMELINE_MUTATION } from '@/store/TimelineSpace'
import { MUTATION_TYPES as HEADER_MUTATION } from '@/store/TimelineSpace/HeaderMenu'
@@ -58,10 +56,6 @@ export default defineComponent({
const { tag } = 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.Hashtag.Tag.timeline)
@@ -80,27 +74,6 @@ export default defineComponent({
store.commit(`TimelineSpace/Contents/${CONTENTS_MUTATION.CHANGE_LOADING}`, false)
})
document.getElementById('scroller')?.addEventListener('scroll', onScroll)
-
- 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(tag, (newTag, _oldTag) => {
store.commit(`TimelineSpace/Contents/${CONTENTS_MUTATION.CHANGE_LOADING}`, true)
@@ -141,7 +114,6 @@ export default defineComponent({
store.dispatch(`${space}/${ACTION_TYPES.STOP_STREAMING}`)
reset()
EventEmitter.off('focus-timeline')
- observer.value?.disconnect()
})
const load = async (tag: string) => {
@@ -170,14 +142,6 @@ export default defineComponent({
}
}
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 &&
@@ -188,17 +152,6 @@ export default defineComponent({
tag: tag.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'),
@@ -212,14 +165,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 updateToot = (toot: Entity.Status) => {
store.commit(`${space}/${MUTATION_TYPES.UPDATE_TOOT}`, toot)
@@ -272,12 +217,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 {
timeline,
@@ -288,7 +227,6 @@ export default defineComponent({
deleteToot,
focusSidebar,
focusToot,
- sizeChanged,
openSideBar,
heading,
upper
diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts b/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
index de5b0e8b..944e2f85 100644
--- a/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
@@ -4,20 +4,18 @@ import { RootState } from '@/store'
import { LoadPositionWithTag } 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 TagState = {
timeline: Array
lazyLoading: boolean
heading: boolean
- scrolling: boolean
}
const state = (): TagState => ({
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
}
}
From fe9898c25d773413312f3690c204649e77e62c16 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 20:54:59 +0900
Subject: [PATCH 6/8] Revert modifying scroll position in Home
---
.../TimelineSpace/Contents/Home.vue | 71 ++-----------------
.../store/TimelineSpace/Contents/Home.ts | 10 +--
2 files changed, 7 insertions(+), 74 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Contents/Home.vue b/src/renderer/components/TimelineSpace/Contents/Home.vue
index b848ff25..1837612b 100644
--- a/src/renderer/components/TimelineSpace/Contents/Home.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Home.vue
@@ -19,7 +19,6 @@
v-on:delete="deleteToot"
@focusRight="focusSidebar"
@selectToot="focusToot(item)"
- @sizeChanged="sizeChanged"
>
@@ -47,7 +46,6 @@ import { useStore } from '@/store'
import Toot from '@/components/organisms/Toot.vue'
import StatusLoading from '@/components/organisms/StatusLoading.vue'
import { EventEmitter } from '@/components/event'
-import { ScrollPosition } from '@/components/utils/scroll'
import { ACTION_TYPES, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Home'
import { MUTATION_TYPES as SIDE_MENU_MUTATION } from '@/store/TimelineSpace/SideMenu'
import { MUTATION_TYPES as TIMELINE_MUTATION } from '@/store/TimelineSpace'
@@ -66,10 +64,6 @@ export default defineComponent({
const { j, k, Ctrl_r } = useMagicKeys()
const focusedId = ref(null)
- const scrollPosition = ref(null)
- const observer = ref(null)
- const scrollTime = ref(null)
- const resizeTime = ref(null)
const loadingMore = ref(false)
const scroller = ref()
@@ -108,30 +102,11 @@ export default defineComponent({
if (heading.value && timeline.value.length > 0) {
store.dispatch(`${space}/${ACTION_TYPES.SAVE_MARKER}`)
}
- const el = document.getElementById('scroller')
- if (el) {
- scrollPosition.value = new ScrollPosition(el)
- scrollPosition.value.prepare()
- observer.value = new ResizeObserver(() => {
- if (loadingMore.value || (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 (store.state.TimelineSpace.SideMenu.unreadHomeTimeline && heading.value) {
store.commit(`TimelineSpace/SideMenu/${SIDE_MENU_MUTATION.CHANGE_UNREAD_HOME_TIMELINE}`, false)
}
- if (scrollPosition.value) {
- scrollPosition.value.prepare()
- }
- })
- onBeforeUnmount(() => {
- observer.value?.disconnect()
})
onUnmounted(() => {
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
@@ -180,39 +155,18 @@ export default defineComponent({
})
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)
- }
-
// for lazyLoading
if (
(event.target as HTMLElement)!.clientHeight + (event.target as HTMLElement)!.scrollTop >=
document.getElementById('scroller')!.scrollHeight - 10 &&
!lazyLoading.value
) {
- store
- .dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_TIMELINE}`, 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'),
- type: 'error'
- })
+ store.dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_TIMELINE}`, timeline.value[timeline.value.length - 1]).catch(() => {
+ ElMessage({
+ message: i18n.t('message.timeline_fetch_error'),
+ type: 'error'
})
+ })
}
if ((event.target as HTMLElement)!.scrollTop > 10 && heading.value) {
@@ -220,14 +174,6 @@ export default defineComponent({
} else if ((event.target as HTMLElement)!.scrollTop <= 5 && !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 updateToot = (message: Entity.Status) => {
store.commit(`${space}/${MUTATION_TYPES.UPDATE_TOOT}`, message)
@@ -275,12 +221,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 {
filteredTimeline,
@@ -296,7 +236,6 @@ export default defineComponent({
focusPrev,
focusSidebar,
focusToot,
- sizeChanged,
openSideBar,
heading,
upper
diff --git a/src/renderer/store/TimelineSpace/Contents/Home.ts b/src/renderer/store/TimelineSpace/Contents/Home.ts
index c5a7646f..838a3f91 100644
--- a/src/renderer/store/TimelineSpace/Contents/Home.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Home.ts
@@ -5,7 +5,7 @@ import { LocalMarker } from '~/src/types/localMarker'
import { MyWindow } from '~/src/types/global'
import { LoadingCard } from '@/types/loading-card'
-const win = window as any as MyWindow
+const win = (window as any) as MyWindow
export type HomeState = {
lazyLoading: boolean
@@ -13,7 +13,6 @@ export type HomeState = {
showReblogs: boolean
showReplies: boolean
timeline: Array
- scrolling: boolean
}
const state = (): HomeState => ({
@@ -21,8 +20,7 @@ const state = (): HomeState => ({
heading: true,
timeline: [],
showReblogs: true,
- showReplies: true,
- scrolling: false
+ showReplies: true
})
export const MUTATION_TYPES = {
@@ -37,7 +35,6 @@ export const MUTATION_TYPES = {
DELETE_TOOT: 'deleteToot',
SHOW_REBLOGS: 'showReblogs',
SHOW_REPLIES: 'showReplies',
- CHANGE_SCROLLING: 'changeScrolling',
APPEND_TIMELINE_AFTER_LOADING_CARD: 'appendTimelineAfterLoadingCard'
}
@@ -106,9 +103,6 @@ const mutations: MutationTree = {
[MUTATION_TYPES.SHOW_REPLIES]: (state, visible: boolean) => {
state.showReplies = visible
},
- [MUTATION_TYPES.CHANGE_SCROLLING]: (state, value: boolean) => {
- state.scrolling = value
- },
[MUTATION_TYPES.APPEND_TIMELINE_AFTER_LOADING_CARD]: (state, timeline: Array) => {
const tl = state.timeline.flatMap(status => {
if (status.id !== 'loading-card') {
From 61c84be1ee637f261a49eb112e76c36516970620 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 21:00:53 +0900
Subject: [PATCH 7/8] Revert modifying scroll position in Notifications
---
.../TimelineSpace/Contents/Notifications.vue | 54 -------------------
.../TimelineSpace/Contents/Notifications.ts | 10 +---
2 files changed, 2 insertions(+), 62 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Contents/Notifications.vue b/src/renderer/components/TimelineSpace/Contents/Notifications.vue
index 8291fcac..62fb4f4b 100644
--- a/src/renderer/components/TimelineSpace/Contents/Notifications.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Notifications.vue
@@ -41,7 +41,6 @@ import { Entity } from 'megalodon'
import Notification from '@/components/organisms/Notification.vue'
import StatusLoading from '@/components/organisms/StatusLoading.vue'
import { EventEmitter } from '@/components/event'
-import { ScrollPosition } from '@/components/utils/scroll'
import { useStore } from '@/store'
import { useRoute } from 'vue-router'
import { useI18next } from 'vue3-i18next'
@@ -64,17 +63,12 @@ export default defineComponent({
const { j, k, Ctrl_r } = useMagicKeys()
const focusedId = ref(null)
- const scrollPosition = ref(null)
- const observer = ref(null)
- const scrollTime = ref(null)
- const resizeTime = ref(null)
const loadingMore = ref(false)
const scroller = ref()
const notifications = computed(() => store.state.TimelineSpace.Contents.Notifications.notifications)
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.Notifications.lazyLoading)
const heading = computed(() => store.state.TimelineSpace.Contents.Notifications.heading)
- const scrolling = computed(() => store.state.TimelineSpace.Contents.Notifications.scrolling)
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const modalOpened = computed(() => store.getters[`TimelineSpace/Modals/modalOpened`])
@@ -91,32 +85,11 @@ export default defineComponent({
if (heading.value && handledNotifications.value.length > 0) {
store.dispatch(`${space}/${ACTION_TYPES.SAVE_MARKER}`)
}
- const el = document.getElementById('scroller')
- if (el) {
- scrollPosition.value = new ScrollPosition(el)
- scrollPosition.value.prepare()
-
- observer.value = new ResizeObserver(() => {
- if (loadingMore.value || (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 (store.state.TimelineSpace.SideMenu.unreadNotifications && heading.value) {
store.commit(`TimelineSpace/SideMenu/${SIDE_MENU_MUTATION.CHANGE_UNREAD_NOTIFICATIONS}`, false)
}
- if (scrollPosition.value) {
- scrollPosition.value.prepare()
- }
- })
- onBeforeUnmount(() => {
- observer.value?.disconnect()
})
onUnmounted(() => {
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
@@ -166,14 +139,6 @@ export default defineComponent({
})
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 &&
@@ -181,17 +146,6 @@ export default defineComponent({
) {
store
.dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_NOTIFICATIONS}`, handledNotifications.value[handledNotifications.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.notification_fetch_error'),
@@ -207,14 +161,6 @@ export default defineComponent({
store.dispatch(`${space}/${ACTION_TYPES.RESET_BADGE}`)
store.dispatch(`${space}/${ACTION_TYPES.SAVE_MARKER}`)
}
-
- setTimeout(() => {
- const now = moment()
- if (now.diff(scrollTime.value) >= 150) {
- scrollTime.value = null
- store.commit(`${space}/${MUTATION_TYPES.CHANGE_SCROLLING}`, false)
- }
- }, 150)
}
const updateToot = (message: Entity.Status) => {
store.commit(`${space}/${MUTATION_TYPES.UPDATE_TOOT}`, message)
diff --git a/src/renderer/store/TimelineSpace/Contents/Notifications.ts b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
index e4f95174..395bf9ff 100644
--- a/src/renderer/store/TimelineSpace/Contents/Notifications.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
@@ -5,20 +5,18 @@ import { LocalMarker } from '~/src/types/localMarker'
import { MyWindow } from '~/src/types/global'
import { LoadingCard } from '@/types/loading-card'
-const win = window as any as MyWindow
+const win = (window as any) as MyWindow
export type NotificationsState = {
lazyLoading: boolean
heading: boolean
notifications: Array
- scrolling: boolean
}
const state = (): NotificationsState => ({
lazyLoading: false,
heading: true,
- notifications: [],
- scrolling: false
+ notifications: []
})
export const MUTATION_TYPES = {
@@ -31,7 +29,6 @@ export const MUTATION_TYPES = {
DELETE_TOOT: 'deleteToot',
CLEAR_NOTIFICATIONS: 'clearNotifications',
ARCHIVE_NOTIFICATIONS: 'archiveNotifications',
- CHANGE_SCROLLING: 'changeScrolling',
APPEND_NOTIFICATIONS_AFTER_LOADING_CARD: 'appendNotificationsAfterLoadingCard'
}
@@ -91,9 +88,6 @@ const mutations: MutationTree = {
[MUTATION_TYPES.ARCHIVE_NOTIFICATIONS]: state => {
state.notifications = state.notifications.slice(0, 30)
},
- [MUTATION_TYPES.CHANGE_SCROLLING]: (state, value: boolean) => {
- state.scrolling = value
- },
[MUTATION_TYPES.APPEND_NOTIFICATIONS_AFTER_LOADING_CARD]: (state, notifications: Array) => {
const n = state.notifications.flatMap(notify => {
if (notify.id !== 'loading-card') {
From 1917cfba6dae53035d747277b22b08de76873078 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Dec 2022 21:15:15 +0900
Subject: [PATCH 8/8] Revert modifying scroll position in Mentions
---
.../Contents/DirectMessages.spec.ts | 2 -
.../Contents/Hashtag/Tag.spec.ts | 2 -
.../store/TimelineSpace/Contents/Home.spec.ts | 6 +-
.../TimelineSpace/Contents/Lists/Show.spec.ts | 2 -
.../TimelineSpace/Contents/Local.spec.ts | 2 -
.../TimelineSpace/Contents/Mentions.spec.ts | 3 -
.../Contents/Notifications.spec.ts | 2 -
.../TimelineSpace/Contents/Public.spec.ts | 6 +-
.../Contents/DirectMessages.spec.ts | 6 --
.../Contents/Hashtag/Tag.spec.ts | 6 --
.../store/TimelineSpace/Contents/Home.spec.ts | 10 ---
.../TimelineSpace/Contents/Lists/Show.spec.ts | 6 --
.../TimelineSpace/Contents/Local.spec.ts | 6 --
.../TimelineSpace/Contents/Mentions.spec.ts | 9 ---
.../Contents/Notifications.spec.ts | 5 --
.../TimelineSpace/Contents/Public.spec.ts | 8 +--
.../TimelineSpace/Contents/DirectMessages.vue | 1 -
.../TimelineSpace/Contents/Hashtag/Tag.vue | 1 -
.../TimelineSpace/Contents/Home.vue | 1 -
.../TimelineSpace/Contents/Lists/Show.vue | 1 -
.../TimelineSpace/Contents/Local.vue | 1 -
.../TimelineSpace/Contents/Mentions.vue | 72 ++-----------------
src/renderer/components/utils/scroll.ts | 22 ------
.../store/TimelineSpace/Contents/Mentions.ts | 10 +--
24 files changed, 12 insertions(+), 178 deletions(-)
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/DirectMessages.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/DirectMessages.spec.ts
index 583847ea..3ee8091f 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/DirectMessages.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/DirectMessages.spec.ts
@@ -135,7 +135,6 @@ let state = (): DirectMessagesState => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: []
}
}
@@ -204,7 +203,6 @@ describe('Home', () => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status1]
}
}
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
index ef694180..1d2573ab 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
@@ -120,7 +120,6 @@ let state = (): TagState => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: []
}
}
@@ -195,7 +194,6 @@ describe('Home', () => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status1]
}
}
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
index 453a8c32..7447e943 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
@@ -121,8 +121,7 @@ let state = (): HomeState => {
heading: true,
timeline: [],
showReblogs: true,
- showReplies: true,
- scrolling: false
+ showReplies: true
}
}
@@ -198,8 +197,7 @@ describe('Home', () => {
timeline: [status1],
unreadTimeline: [],
showReblogs: true,
- showReplies: true,
- scrolling: false
+ showReplies: true
}
}
})
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Show.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Show.spec.ts
index 09c66b6d..035c9150 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Show.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Show.spec.ts
@@ -122,7 +122,6 @@ let state = (): ShowState => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: []
}
}
@@ -195,7 +194,6 @@ describe('Lists/Show', () => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status1]
}
}
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Local.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Local.spec.ts
index f005c3c8..f984f447 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Local.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Local.spec.ts
@@ -119,7 +119,6 @@ let state = (): LocalState => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: []
}
}
@@ -187,7 +186,6 @@ describe('Home', () => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status1]
}
}
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts
index e6494c5e..ce000e54 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts
@@ -190,7 +190,6 @@ describe('Mentions', () => {
return {
lazyLoading: true,
heading: true,
- scrolling: false,
mentions: []
}
}
@@ -207,7 +206,6 @@ describe('Mentions', () => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
mentions: [mention, reblog]
}
}
@@ -238,7 +236,6 @@ describe('Mentions', () => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
mentions: [mention, favourite, reblog, follow]
}
}
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
index deac7e07..f52f4370 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
@@ -195,7 +195,6 @@ let state = (): NotificationsState => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
notifications: []
}
}
@@ -270,7 +269,6 @@ describe('Notifications', () => {
return {
lazyLoading: false,
heading: true,
- scrolling: false,
notifications: [notification1]
}
}
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Public.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Public.spec.ts
index 3981581e..259d647e 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Public.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Public.spec.ts
@@ -119,8 +119,7 @@ let state = (): PublicState => {
return {
lazyLoading: false,
heading: true,
- timeline: [],
- scrolling: false
+ timeline: []
}
}
@@ -187,8 +186,7 @@ describe('Home', () => {
return {
lazyLoading: false,
heading: true,
- timeline: [status1],
- scrolling: false
+ timeline: [status1]
}
}
})
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
index 4d9cece6..d66dc7e2 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
@@ -139,7 +139,6 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -154,7 +153,6 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, rebloggedStatus]
}
})
@@ -172,7 +170,6 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -187,7 +184,6 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [rebloggedStatus, status2, status1]
}
})
@@ -204,7 +200,6 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -219,7 +214,6 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [rebloggedStatus, status2, status1]
}
})
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
index 2c8f0d05..0e5efa2c 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
@@ -139,7 +139,6 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -154,7 +153,6 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, rebloggedStatus]
}
})
@@ -172,7 +170,6 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -187,7 +184,6 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [rebloggedStatus, status2, status1]
}
})
@@ -204,7 +200,6 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -219,7 +214,6 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [rebloggedStatus, status2, status1]
}
})
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
index 290e4e26..75fdfc6a 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
@@ -100,7 +100,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [],
showReblogs: true,
showReplies: true
@@ -128,7 +127,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status1],
showReblogs: true,
showReplies: true
@@ -145,7 +143,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1],
showReblogs: true,
showReplies: true
@@ -164,7 +161,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [status1],
showReblogs: true,
showReplies: true
@@ -180,7 +176,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [status2, status1],
showReblogs: true,
showReplies: true
@@ -199,7 +194,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status1],
showReblogs: true,
showReplies: true
@@ -217,7 +211,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status1, status2],
showReblogs: true,
showReplies: true
@@ -274,7 +267,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [rebloggedStatus, status2],
showReblogs: true,
showReplies: true
@@ -294,7 +286,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status1, status2],
showReblogs: true,
showReplies: true
@@ -346,7 +337,6 @@ describe('TimelineSpace/Contents/Home', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [rebloggedStatus, status2],
showReblogs: true,
showReplies: true
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
index 74b0157f..91107644 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
@@ -139,7 +139,6 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -154,7 +153,6 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, rebloggedStatus]
}
})
@@ -172,7 +170,6 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -187,7 +184,6 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [rebloggedStatus, status2, status1]
}
})
@@ -204,7 +200,6 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -219,7 +214,6 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [rebloggedStatus, status2, status1]
}
})
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
index 636b6bf9..7dd0ca02 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
@@ -139,7 +139,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -154,7 +153,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, rebloggedStatus]
}
})
@@ -171,7 +169,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -186,7 +183,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
timeline: [rebloggedStatus, status2, status1]
}
})
@@ -203,7 +199,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [status2, status1]
}
})
@@ -218,7 +213,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
timeline: [rebloggedStatus, status2, status1]
}
})
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
index 61624fce..73e49a6a 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
@@ -176,7 +176,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
mentions: []
}
})
@@ -188,7 +187,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
mentions: [notification1]
}
})
@@ -203,7 +201,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
mentions: [notification2, notification1]
}
})
@@ -220,7 +217,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
mentions: [notification1]
}
})
@@ -235,7 +231,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
mentions: [notification2, notification1]
}
})
@@ -252,7 +247,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
mentions: [notification2]
}
})
@@ -267,7 +261,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
mentions: [notification2, notification1]
}
})
@@ -287,7 +280,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
mentions: [notification2, notification1]
}
})
@@ -301,7 +293,6 @@ describe('TimelineSpace/Contents/Mentions', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
mentions: [notification2, notification1]
}
})
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
index 3f41ede0..95e468a8 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
@@ -178,7 +178,6 @@ describe('TimelineSpace/Contents/Notifications', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
notifications: [notification2, notification1]
}
})
@@ -203,7 +202,6 @@ describe('TimelineSpace/Contents/Notifications', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
notifications: [notification1]
}
})
@@ -218,7 +216,6 @@ describe('TimelineSpace/Contents/Notifications', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: false,
notifications: [notification2, notification1]
}
})
@@ -235,7 +232,6 @@ describe('TimelineSpace/Contents/Notifications', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
notifications: [notification1]
}
})
@@ -249,7 +245,6 @@ describe('TimelineSpace/Contents/Notifications', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: false,
notifications: [notification2, notification1]
}
})
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
index 547e56ed..6feec1bb 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
@@ -139,8 +139,7 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: true,
- timeline: [status2, status1],
- scrolling: false
+ timeline: [status2, status1]
}
})
it('should be deleted', () => {
@@ -154,7 +153,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: true,
timeline: [status2, rebloggedStatus]
}
})
@@ -172,7 +170,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: true,
timeline: [status2, status1]
}
})
@@ -187,7 +184,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: true,
- scrolling: true,
timeline: [rebloggedStatus, status2, status1]
}
})
@@ -204,7 +200,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: true,
timeline: [status2, status1]
}
})
@@ -219,7 +214,6 @@ describe('TimelineSpace/Contents/Local', () => {
state = {
lazyLoading: false,
heading: false,
- scrolling: true,
timeline: [rebloggedStatus, status2, status1]
}
})
diff --git a/src/renderer/components/TimelineSpace/Contents/DirectMessages.vue b/src/renderer/components/TimelineSpace/Contents/DirectMessages.vue
index a4a83517..c59a88ec 100644
--- a/src/renderer/components/TimelineSpace/Contents/DirectMessages.vue
+++ b/src/renderer/components/TimelineSpace/Contents/DirectMessages.vue
@@ -61,7 +61,6 @@ export default defineComponent({
const timeline = computed(() => store.state.TimelineSpace.Contents.DirectMessages.timeline)
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.DirectMessages.lazyLoading)
const heading = computed(() => store.state.TimelineSpace.Contents.DirectMessages.heading)
- const scrolling = computed(() => store.state.TimelineSpace.Contents.DirectMessages.scrolling)
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const unreadNotification = computed(() => store.state.TimelineSpace.timelineSetting.unreadNotification)
diff --git a/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue b/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
index e8af8fd6..8ba10b46 100644
--- a/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
@@ -61,7 +61,6 @@ export default defineComponent({
const timeline = computed(() => store.state.TimelineSpace.Contents.Hashtag.Tag.timeline)
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.Hashtag.Tag.lazyLoading)
const heading = computed(() => store.state.TimelineSpace.Contents.Hashtag.Tag.heading)
- const scrolling = computed(() => store.state.TimelineSpace.Contents.Hashtag.Tag.scrolling)
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const modalOpened = computed(() => store.getters[`TimelineSpace/Modals/modalOpened`])
diff --git a/src/renderer/components/TimelineSpace/Contents/Home.vue b/src/renderer/components/TimelineSpace/Contents/Home.vue
index 1837612b..d2fd428f 100644
--- a/src/renderer/components/TimelineSpace/Contents/Home.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Home.vue
@@ -72,7 +72,6 @@ export default defineComponent({
const heading = computed(() => store.state.TimelineSpace.Contents.Home.heading)
const showReblogs = computed(() => store.state.TimelineSpace.Contents.Home.showReblogs)
const showReplies = computed(() => store.state.TimelineSpace.Contents.Home.showReplies)
- const scrolling = computed(() => store.state.TimelineSpace.Contents.Home.scrolling)
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const modalOpened = computed(() => store.getters[`TimelineSpace/Modals/modalOpened`])
diff --git a/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue b/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
index be2bc019..10859741 100644
--- a/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
@@ -58,7 +58,6 @@ export default defineComponent({
const timeline = computed(() => store.state.TimelineSpace.Contents.Lists.Show.timeline)
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.Lists.Show.lazyLoading)
const heading = computed(() => store.state.TimelineSpace.Contents.Lists.Show.heading)
- const scrolling = computed(() => store.state.TimelineSpace.Contents.Lists.Show.scrolling)
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const modalOpened = computed(() => store.getters[`TimelineSpace/Modals/modalOpened`])
diff --git a/src/renderer/components/TimelineSpace/Contents/Local.vue b/src/renderer/components/TimelineSpace/Contents/Local.vue
index 2df34e9a..51356f79 100644
--- a/src/renderer/components/TimelineSpace/Contents/Local.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Local.vue
@@ -61,7 +61,6 @@ export default defineComponent({
const timeline = computed(() => store.state.TimelineSpace.Contents.Local.timeline)
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.Local.lazyLoading)
const heading = computed(() => store.state.TimelineSpace.Contents.Local.heading)
- const scrolling = computed(() => store.state.TimelineSpace.Contents.Local.scrolling)
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const unreadNotification = computed(() => store.state.TimelineSpace.timelineSetting.unreadNotification)
diff --git a/src/renderer/components/TimelineSpace/Contents/Mentions.vue b/src/renderer/components/TimelineSpace/Contents/Mentions.vue
index 7b9c50bc..58be6a82 100644
--- a/src/renderer/components/TimelineSpace/Contents/Mentions.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Mentions.vue
@@ -18,7 +18,6 @@
v-on:update="updateToot"
@focusRight="focusSidebar"
@selectNotification="focusNotification(item)"
- @sizeChanged="sizeChanged"
>
@@ -45,7 +44,6 @@ import { useStore } from '@/store'
import Notification from '@/components/organisms/Notification.vue'
import StatusLoading from '@/components/organisms/StatusLoading.vue'
import { EventEmitter } from '@/components/event'
-import { ScrollPosition } from '@/components/utils/scroll'
import useReloadable from '@/components/utils/reloadable'
import { LoadingCard } from '@/types/loading-card'
import { ACTION_TYPES, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Mentions'
@@ -65,17 +63,12 @@ export default defineComponent({
const { j, k, Ctrl_r } = useMagicKeys()
const focusedId = ref(null)
- const scrollPosition = ref(null)
- const observer = ref(null)
- const scrollTime = ref(null)
- const resizeTime = ref(null)
const loadingMore = ref(false)
const scroller = ref()
const mentions = computed>(() => store.getters[`${space}/mentions`])
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.Mentions.lazyLoading)
const heading = computed(() => store.state.TimelineSpace.Contents.Mentions.heading)
- const scrolling = computed(() => store.state.TimelineSpace.Contents.Mentions.scrolling)
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const modalOpened = computed(() => store.getters[`TimelineSpace/Modals/modalOpened`])
@@ -89,30 +82,11 @@ export default defineComponent({
if (heading.value && mentions.value.length > 0) {
store.dispatch(`${space}/${ACTION_TYPES.SAVE_MARKER}`)
}
- const el = document.getElementById('scroller')
- if (el) {
- scrollPosition.value = new ScrollPosition(el)
- scrollPosition.value.prepare()
- observer.value = new ResizeObserver(() => {
- if (loadingMore.value || (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 (store.state.TimelineSpace.SideMenu.unreadMentions && heading.value) {
store.commit(`TimelineSpace/SideMenu/${SIDE_MENU_MUTATION.CHANGE_UNREAD_MENTIONS}`, false)
}
- if (scrollPosition.value) {
- scrollPosition.value.prepare()
- }
- })
- onBeforeUnmount(() => {
- observer.value?.disconnect()
})
onUnmounted(() => {
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
@@ -161,39 +135,18 @@ export default defineComponent({
})
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)
- }
-
// for lazyLoading
if (
(event.target as HTMLElement)!.clientHeight + (event.target as HTMLElement)!.scrollTop >=
document.getElementById('scroller')!.scrollHeight - 10 &&
!lazyLoading.value
) {
- store
- .dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_MENTIONS}`, mentions.value[mentions.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'),
- type: 'error'
- })
+ store.dispatch(`${space}/${ACTION_TYPES.LAZY_FETCH_MENTIONS}`, mentions.value[mentions.value.length - 1]).catch(() => {
+ ElMessage({
+ message: i18n.t('message.timeline_fetch_error'),
+ type: 'error'
})
+ })
}
if ((event.target as HTMLElement)!.scrollTop > 10 && heading.value) {
@@ -202,14 +155,6 @@ export default defineComponent({
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
store.dispatch(`${space}/${ACTION_TYPES.SAVE_MARKER}`)
}
-
- setTimeout(() => {
- const now = moment()
- if (now.diff(scrollTime.value) >= 150) {
- scrollTime.value = null
- store.commit(`${space}/${MUTATION_TYPES.CHANGE_SCROLLING}`, false)
- }
- }, 150)
}
const updateToot = (message: Entity.Status) => {
store.commit(`${space}/${MUTATION_TYPES.UPDATE_TOOT}`, message)
@@ -254,12 +199,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 {
mentions,
@@ -271,7 +210,6 @@ export default defineComponent({
updateToot,
focusSidebar,
focusNotification,
- sizeChanged,
openSideBar,
heading,
upper
diff --git a/src/renderer/components/utils/scroll.ts b/src/renderer/components/utils/scroll.ts
index 26a06060..e2a0bb0a 100644
--- a/src/renderer/components/utils/scroll.ts
+++ b/src/renderer/components/utils/scroll.ts
@@ -35,25 +35,3 @@ export default function scrollTop(element: HTMLElement, point: number = 0) {
const easeOut = function (p: number) {
return p * (2 - p)
}
-
-export class ScrollPosition {
- private node: HTMLElement | null = null
- private previousScrollHeightMinusTop: number = 0
-
- constructor(node: HTMLElement) {
- this.node = node
- this.previousScrollHeightMinusTop = 0
- }
-
- prepare() {
- if (this.node) {
- this.previousScrollHeightMinusTop = this.node.scrollHeight - this.node.scrollTop
- }
- }
-
- restore() {
- if (this.node) {
- this.node.scrollTop = this.node.scrollHeight - this.previousScrollHeightMinusTop
- }
- }
-}
diff --git a/src/renderer/store/TimelineSpace/Contents/Mentions.ts b/src/renderer/store/TimelineSpace/Contents/Mentions.ts
index a1af920b..71af25eb 100644
--- a/src/renderer/store/TimelineSpace/Contents/Mentions.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Mentions.ts
@@ -5,7 +5,7 @@ import { MyWindow } from '~/src/types/global'
import { LoadingCard } from '@/types/loading-card'
import { LocalMarker } from '~/src/types/localMarker'
-const win = window as any as MyWindow
+const win = (window as any) as MyWindow
const excludes: Array = [
NotificationType.Follow,
@@ -20,14 +20,12 @@ export type MentionsState = {
lazyLoading: boolean
heading: boolean
mentions: Array
- scrolling: boolean
}
const state = (): MentionsState => ({
lazyLoading: false,
heading: true,
- mentions: [],
- scrolling: false
+ mentions: []
})
export const MUTATION_TYPES = {
@@ -40,7 +38,6 @@ export const MUTATION_TYPES = {
CLEAR_MENTIONS: 'clearMentions',
UPDATE_TOOT: 'updateToot',
DELETE_TOOT: 'deleteToot',
- CHANGE_SCROLLING: 'changeScrolling',
APPEND_MENTIONS_AFTER_LOADING_CARD: 'appendMentionsAfterLoadingCard'
}
@@ -98,9 +95,6 @@ const mutations: MutationTree = {
}
})
},
- [MUTATION_TYPES.CHANGE_SCROLLING]: (state, value: boolean) => {
- state.scrolling = value
- },
[MUTATION_TYPES.APPEND_MENTIONS_AFTER_LOADING_CARD]: (state, mentions: Array) => {
const m = state.mentions.flatMap(mention => {
if (mention.id !== 'loading-card') {