summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfgang <github@linux-dude.de>2024-10-10 16:38:01 +0000
committerBenjamin Brahmer <info@b-brahmer.de>2024-10-14 09:16:19 +0200
commit099648fa4ce85be4ce324c62ad8399e7d54a61e7 (patch)
tree9f36c1a848fd55cde92dbfc6c66194a7b4650dd0
parent4e583b7feb21d3068ebfbe95e20d36b7750d2869 (diff)
fix: Uncaught TypeError when response is empty
Signed-off-by: Wolfgang <github@linux-dude.de>
-rw-r--r--src/store/item.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/store/item.ts b/src/store/item.ts
index ecb269460..b84ea69a4 100644
--- a/src/store/item.ts
+++ b/src/store/item.ts
@@ -84,9 +84,11 @@ export const actions = {
commit(FEED_ITEM_MUTATION_TYPES.SET_ALL_LOADED, { key: 'unread', loaded: true })
}
- const lastItem = response?.data.items[response?.data.items.length - 1].id
- commit(FEED_ITEM_MUTATION_TYPES.SET_LAST_ITEM_LOADED, { key: 'unread', lastItem })
- commit(FEED_ITEM_MUTATION_TYPES.SET_FETCHING, { key: 'unread', fetching: false })
+ if (response?.data.items.length > 0) {
+ const lastItem = response?.data.items[response?.data.items.length - 1].id
+ commit(FEED_ITEM_MUTATION_TYPES.SET_LAST_ITEM_LOADED, { key: 'unread', lastItem })
+ commit(FEED_ITEM_MUTATION_TYPES.SET_FETCHING, { key: 'unread', fetching: false })
+ }
},
/**