Skip to content

Commit

Permalink
add: keyboard shortcuts "u", "s", "i", "l" and "o"
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Jun 3, 2024
1 parent d1aa733 commit e3fc60f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ You can also check [on GitHub](https://github.com/nextcloud/news/releases), the
### Changed
- added alternative development environment (#2670)
- Implement `j` and `k` keyboards shortcuts for navigating through feed items (#2671)
- Implement `s`, `i` and `l` keyboards shortcuts for staring current feed item (#2677)
- Implement `o` keyboards shortcut for opening the url of current feed item (#2677)
- Implement `u` keyboards shortcut for marking current feed item read/unread (#2677)
- Implement highlighting of active feed item (#2677)

### Fixed
Expand Down
24 changes: 24 additions & 0 deletions src/components/feed-display/FeedItemDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
</NcActionButton>
</NcActions>
<StarIcon :class="{'starred': item.starred }" @click="toggleStarred(item)" />
<EyeIcon v-if="item.unread" @click="toggleRead(item)" />
<EyeCheckIcon v-if="!item.unread" @click="toggleRead(item)" />
<CloseIcon @click="clearSelected()" />
<button v-shortkey="{s: ['s'], l: ['l'], i: ['i']}" class="hidden" @shortkey="toggleStarred(item)" />
<button v-shortkey="['o']" class="hidden" @shortkey="openUrl(item)" />
<button v-shortkey="['u']" class="hidden" @shortkey="toggleRead(item)" />
</div>
<div class="article">
<div class="heading">
Expand Down Expand Up @@ -109,10 +114,14 @@ import ShareItem from '../ShareItem.vue'
import { Feed } from '../../types/Feed'
import { FeedItem } from '../../types/FeedItem'
import { ACTIONS, MUTATIONS } from '../../store'
import EyeIcon from 'vue-material-design-icons/Eye.vue'
import EyeCheckIcon from 'vue-material-design-icons/EyeCheck.vue'
export default Vue.extend({
name: 'FeedItemDisplay',
components: {
EyeCheckIcon,
EyeIcon,
CloseIcon,
StarIcon,
ShareVariant,
Expand Down Expand Up @@ -170,6 +179,21 @@ export default Vue.extend({
this.$store.dispatch(item.starred ? ACTIONS.UNSTAR_ITEM : ACTIONS.STAR_ITEM, { item })
},
toggleRead(item: FeedItem): void {
if (item.unread) {
this.$store.dispatch(ACTIONS.MARK_READ, { item })
} else {
this.$store.dispatch(ACTIONS.MARK_UNREAD, { item })
}
},
openUrl(item: FeedItem): void {
// Open the item url in a new tab
if (item.url) {
window.open(item.url, '_blank')
}
},
closeShareMenu() {
this.showShareMenu = false
},
Expand Down
1 change: 1 addition & 0 deletions src/types/FeedItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export type FeedItem = {
feedId: number;
guidHash: string;
pubDate: number;
url: string;
};

0 comments on commit e3fc60f

Please sign in to comment.