Skip to content

Commit

Permalink
add: make first attempt to jump to previous and next feed item
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed May 24, 2024
1 parent fdfe00a commit f321ebb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/components/feed-display/FeedItemDisplayList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import VirtualScroll from './VirtualScroll.vue'
import FeedItemRow from './FeedItemRow.vue'
import { FeedItem } from '../../types/FeedItem'
import {ACTIONS, MUTATIONS} from '../../store'

Check failure on line 65 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint node

A space is required after '{'

Check warning on line 65 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint node

'ACTIONS' is defined but never used

Check failure on line 65 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint node

A space is required before '}'

Check failure on line 65 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint

A space is required after '{'

Check warning on line 65 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint

'ACTIONS' is defined but never used

Check failure on line 65 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint

A space is required before '}'
const DEFAULT_DISPLAY_LIST_CONFIG = {
starFilter: true,
Expand Down Expand Up @@ -126,6 +127,12 @@ export default Vue.extend({
cfg() {
return _.defaults({ ...this.config }, DEFAULT_DISPLAY_LIST_CONFIG)
},
allItems() {
return this.$store.getters.allItems
},
selectedItem() {
return this.$store.getters.selected
},
},
mounted() {
this.mounted = true
Expand Down Expand Up @@ -177,11 +184,33 @@ export default Vue.extend({
return response.sort(this.sort)
},
// TODO: Make jumpToPreviousItem() work correctly in all circumstances (like the "Unread articles" or "All articles" view)
// TODO: Make jumpToPreviousItem() highlight the current item
// TODO: Make jumpToPreviousItem() set MARK_READ if needed
jumpToPreviousItem() {
console.log('Previous item')

Check warning on line 191 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint node

Unexpected console statement

Check warning on line 191 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
const currentIndex = this.selectedItem ? this.allItems.findIndex((item: FeedItem) => item.id === this.selectedItem.id) || 0 : 0
console.log('currentIndex', currentIndex)

Check warning on line 193 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint node

Unexpected console statement

Check warning on line 193 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
if (currentIndex > 0) {
const previousItem = this.allItems[currentIndex - 1]
console.log('previousItem', previousItem)
this.$store.commit(MUTATIONS.SET_SELECTED_ITEM, {id: previousItem.id})

Check failure on line 197 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint node

A space is required after '{'

Check failure on line 197 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint node

A space is required before '}'

Check failure on line 197 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint

A space is required after '{'

Check failure on line 197 in src/components/feed-display/FeedItemDisplayList.vue

View workflow job for this annotation

GitHub Actions / eslint

A space is required before '}'
// this.$store.dispatch(ACTIONS.MARK_READ, { previousItem })
}
},
// TODO: Make jumpToNextItem() work correctly in all circumstances (like the "Unread articles" or "All articles" view)
// TODO: Make jumpToNextItem() highlight the current item
// TODO: Make jumpToNextItem() set MARK_READ if needed
jumpToNextItem() {
console.log('Next item')
const currentIndex = this.selectedItem ? this.allItems.findIndex((item: FeedItem) => item.id === this.selectedItem.id) || 0 : 0
console.log('currentIndex', currentIndex)
if (currentIndex !== -1 && currentIndex < this.allItems.length - 1) {
const nextItem = this.allItems[currentIndex + 1]
console.log('nextItem', nextItem)
this.$store.commit(MUTATIONS.SET_SELECTED_ITEM, { id: nextItem.id })
// this.$store.dispatch(ACTIONS.MARK_READ, { nextItem })
}
},
},
})
Expand Down

0 comments on commit f321ebb

Please sign in to comment.