mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 12:18:30 +03:00
. (period) keyboard shortcut = load new posts
This commit is contained in:
parent
96387c8abb
commit
ecd5c7b91e
2 changed files with 28 additions and 18 deletions
|
@ -71,6 +71,10 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
action: 'Load new posts',
|
||||
keys: <kbd>.</kbd>,
|
||||
},
|
||||
{
|
||||
action: 'Open post details',
|
||||
keys: (
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue