
BREAKING CHANGE: Node v12.20+, v14.14+, or v16.0+ is required * fix!: remove esm package, use native Node ES modules * fix: fix some CJS imports
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
import { showMoreItemsForCurrentTimeline } from './timeline.js'
|
|
import { scrollToTop } from '../_utils/scrollToTop.js'
|
|
import { createStatusOrNotificationUuid } from '../_utils/createStatusOrNotificationUuid.js'
|
|
import { store } from '../_store/store.js'
|
|
import { tryToFocusElement } from '../_utils/tryToFocusElement.js'
|
|
|
|
export function showMoreAndScrollToTop () {
|
|
// Similar to Twitter, pressing "." will click the "show more" button and select
|
|
// the first toot.
|
|
showMoreItemsForCurrentTimeline()
|
|
const {
|
|
currentInstance,
|
|
timelineItemSummaries,
|
|
currentTimelineType,
|
|
currentTimelineValue
|
|
} = store.get()
|
|
const firstItemSummary = timelineItemSummaries && timelineItemSummaries[0]
|
|
if (!firstItemSummary) {
|
|
return
|
|
}
|
|
const notificationId = currentTimelineType === 'notifications' && firstItemSummary.id
|
|
const statusId = currentTimelineType !== 'notifications' && firstItemSummary.id
|
|
scrollToTop(/* smooth */ false)
|
|
const id = createStatusOrNotificationUuid(
|
|
currentInstance, currentTimelineType,
|
|
currentTimelineValue, notificationId, statusId
|
|
)
|
|
tryToFocusElement(id)
|
|
}
|