2021-07-04 20:19:04 -07:00
|
|
|
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'
|
2019-03-18 09:09:24 -07:00
|
|
|
|
|
|
|
export function showMoreAndScrollToTop () {
|
|
|
|
// Similar to Twitter, pressing "." will click the "show more" button and select
|
|
|
|
// the first toot.
|
|
|
|
showMoreItemsForCurrentTimeline()
|
2019-08-03 13:49:37 -07:00
|
|
|
const {
|
2019-03-18 09:09:24 -07:00
|
|
|
currentInstance,
|
|
|
|
timelineItemSummaries,
|
|
|
|
currentTimelineType,
|
|
|
|
currentTimelineValue
|
|
|
|
} = store.get()
|
2019-08-03 13:49:37 -07:00
|
|
|
const firstItemSummary = timelineItemSummaries && timelineItemSummaries[0]
|
2019-03-18 09:09:24 -07:00
|
|
|
if (!firstItemSummary) {
|
|
|
|
return
|
|
|
|
}
|
2019-08-03 13:49:37 -07:00
|
|
|
const notificationId = currentTimelineType === 'notifications' && firstItemSummary.id
|
|
|
|
const statusId = currentTimelineType !== 'notifications' && firstItemSummary.id
|
2019-03-18 09:09:24 -07:00
|
|
|
scrollToTop(/* smooth */ false)
|
2020-04-26 16:54:00 -07:00
|
|
|
const id = createStatusOrNotificationUuid(
|
|
|
|
currentInstance, currentTimelineType,
|
|
|
|
currentTimelineValue, notificationId, statusId
|
|
|
|
)
|
|
|
|
tryToFocusElement(id)
|
2019-03-18 09:09:24 -07:00
|
|
|
}
|