. (period) keyboard shortcut = load new posts

pull/393/head
Lim Chee Aun 2024-01-07 14:47:17 +08:00
rodzic 96387c8abb
commit ecd5c7b91e
2 zmienionych plików z 28 dodań i 18 usunięć

Wyświetl plik

@ -71,6 +71,10 @@ export default memo(function KeyboardShortcutsHelp() {
</>
),
},
{
action: 'Load new posts',
keys: <kbd>.</kbd>,
},
{
action: 'Open post details',
keys: (

Wyświetl plik

@ -204,6 +204,21 @@ function Timeline({
}
});
const showNewPostsIndicator =
items.length > 0 && uiState !== 'loading' && showNew;
const handleLoadNewPosts = useCallback(() => {
loadItems(true);
scrollableRef.current?.scrollTo({
top: 0,
behavior: 'smooth',
});
}, [loadItems]);
const dotRef = useHotkeys('.', () => {
if (showNewPostsIndicator) {
handleLoadNewPosts();
}
});
// const {
// scrollDirection,
// nearReachStart,
@ -387,24 +402,15 @@ function Timeline({
{!!headerEnd && headerEnd}
</div>
</div>
{items.length > 0 &&
uiState !== 'loading' &&
// !hiddenUI &&
showNew && (
<button
class="updates-button shiny-pill"
type="button"
onClick={() => {
loadItems(true);
scrollableRef.current?.scrollTo({
top: 0,
behavior: 'smooth',
});
}}
>
<Icon icon="arrow-up" /> New posts
</button>
)}
{showNewPostsIndicator && (
<button
class="updates-button shiny-pill"
type="button"
onClick={handleLoadNewPosts}
>
<Icon icon="arrow-up" /> New posts
</button>
)}
</header>
{!!timelineStart && (
<div