Skip to content

Commit

Permalink
feat: . shortcut to show new items (#2612)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Feb 24, 2024
1 parent 082650d commit 3769176
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions components/magickeys/MagickeysKeyboardShortcuts.vue
Expand Up @@ -65,6 +65,10 @@ const shortcutItemGroups = computed<ShortcutItemGroup[]>(() => [
description: t('magic_keys.groups.actions.compose'),
shortcut: { keys: ['c'], isSequence: false },
},
{
description: t('magic_keys.groups.actions.show_new_items'),
shortcut: { keys: ['.'], isSequence: false },
},
{
description: t('magic_keys.groups.actions.favourite'),
shortcut: { keys: ['f'], isSequence: false },
Expand Down
2 changes: 1 addition & 1 deletion components/notification/NotificationPaginator.vue
Expand Up @@ -174,7 +174,7 @@ const { formatNumber } = useHumanReadableNumber()
:virtualScroller="virtualScroller"
>
<template #updater="{ number, update }">
<button py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="() => { update(); clearNotifications() }">
<button id="elk_show_new_items" py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="() => { update(); clearNotifications() }">
{{ $t('timeline.show_new_items', number, { named: { v: formatNumber(number) } }) }}
</button>
</template>
Expand Down
2 changes: 1 addition & 1 deletion components/timeline/TimelinePaginator.vue
Expand Up @@ -25,7 +25,7 @@ const showOriginSite = computed(() =>
<template>
<CommonPaginator v-bind="{ paginator, stream, preprocess, buffer, endMessage }" :virtual-scroller="virtualScroller">
<template #updater="{ number, update }">
<button py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="update">
<button id="elk_show_new_items" py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="update">
{{ $t('timeline.show_new_items', number, { named: { v: formatNumber(number) } }) }}
</button>
</template>
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Expand Up @@ -228,6 +228,7 @@
"compose": "Compose",
"favourite": "Favourite",
"search": "Search",
"show_new_items": "Show new items",
"title": "Actions"
},
"media": {
Expand Down
1 change: 1 addition & 0 deletions locales/es.json
Expand Up @@ -228,6 +228,7 @@
"compose": "Redactar",
"favourite": "Favorito",
"search": "Búsqueda",
"show_new_items": "Mostrar nuevas publicaciones",
"title": "Acciones"
},
"media": {
Expand Down
8 changes: 8 additions & 0 deletions plugins/magic-keys.client.ts
Expand Up @@ -55,4 +55,12 @@ export default defineNuxtPlugin(({ $scrollToTop }) => {
?.click()
}
whenever(logicAnd(isAuthenticated, notUsingInput, keys.b), toggleBoostActiveStatus)

const showNewItems = () => {
// TODO: find a better solution than clicking buttons...
document
?.querySelector<HTMLElement>('button#elk_show_new_items')
?.click()
}
whenever(logicAnd(isAuthenticated, notUsingInput, keys['.']), showNewItems)
})

0 comments on commit 3769176

Please sign in to comment.