From 9a2252781b99f7f394d4d9d29b208febb295729f Mon Sep 17 00:00:00 2001 From: Devlin Junker Date: Tue, 8 Aug 2023 22:55:03 -0700 Subject: [PATCH 1/9] started on fetching starred items from backend and displaying with for loop Signed-off-by: Devlin Junker --- src/components/Starred.vue | 24 +++++++++++----- src/store/folder.ts | 4 +-- src/store/index.ts | 8 ++++-- src/store/item.ts | 56 ++++++++++++++++++++++++++++++++++++++ src/types/ApiRoutes.ts | 1 + src/types/MutationTypes.ts | 4 +++ 6 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 src/store/item.ts diff --git a/src/components/Starred.vue b/src/components/Starred.vue index d1117d1372..d0f51ab458 100644 --- a/src/components/Starred.vue +++ b/src/components/Starred.vue @@ -1,20 +1,30 @@ - diff --git a/src/components/FeedItem.vue b/src/components/FeedItem.vue new file mode 100644 index 0000000000..880178e16e --- /dev/null +++ b/src/components/FeedItem.vue @@ -0,0 +1,56 @@ + + + diff --git a/src/components/ItemSkeleton.vue b/src/components/ItemSkeleton.vue new file mode 100644 index 0000000000..3b3b3f50cc --- /dev/null +++ b/src/components/ItemSkeleton.vue @@ -0,0 +1,28 @@ + + + + diff --git a/src/components/Starred.vue b/src/components/Starred.vue index d0f51ab458..b35e472d1a 100644 --- a/src/components/Starred.vue +++ b/src/components/Starred.vue @@ -1,18 +1,24 @@ + + diff --git a/src/store/item.ts b/src/store/item.ts index 09a6b6f968..d108e34a7d 100644 --- a/src/store/item.ts +++ b/src/store/item.ts @@ -3,17 +3,24 @@ import axios from '@nextcloud/axios' import { ActionParams } from '../store' import { FEED_ITEM_MUTATION_TYPES } from '../types/MutationTypes' import { API_ROUTES } from '../types/ApiRoutes' +import { FeedItem } from '../types/FeedItem' export const FEED_ITEM_ACTION_TYPES = { FETCH_STARRED: 'FETCH_STARRED', } export type ItemState = { - allItems: any[]; - starredItems: any[]; + fetchingItems: boolean; + starredLoaded: boolean; + + allItems: FeedItem[]; + starredItems: FeedItem[]; } const state: ItemState = { + fetchingItems: false, + starredLoaded: false, + allItems: [], starredItems: [], } @@ -26,6 +33,7 @@ const getters = { export const actions = { async [FEED_ITEM_ACTION_TYPES.FETCH_STARRED]({ commit }: ActionParams) { + state.fetchingItems = true const response = await axios.get(API_ROUTES.ITEMS, { params: { limit: 40, @@ -33,15 +41,21 @@ export const actions = { search: '', showAll: false, type: 2, + offset: 0, }, }) commit(FEED_ITEM_MUTATION_TYPES.SET_STARRED, response.data.items) + + if (response.data.items.length < 40) { + state.starredLoaded = true + } + state.fetchingItems = false }, } export const mutations = { - [FEED_ITEM_MUTATION_TYPES.SET_STARRED](state: ItemState, items: any[]) { + [FEED_ITEM_MUTATION_TYPES.SET_STARRED](state: ItemState, items: FeedItem[]) { items.forEach(it => { state.starredItems.push(it) }) diff --git a/src/types/FeedItem.ts b/src/types/FeedItem.ts new file mode 100644 index 0000000000..7ffe461c71 --- /dev/null +++ b/src/types/FeedItem.ts @@ -0,0 +1,4 @@ +export type FeedItem = { + id: string; + title: string; +}; From 9157a885c13c746935236a28bcb5113a3c737669 Mon Sep 17 00:00:00 2001 From: Devlin Junker Date: Mon, 14 Aug 2023 21:40:21 -0700 Subject: [PATCH 3/9] some cleanup and improvements Signed-off-by: Devlin Junker --- src/components/FeedItem.vue | 56 +++++++++++++++++++++++++++---------- src/components/Starred.vue | 7 +++-- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/components/FeedItem.vue b/src/components/FeedItem.vue index 880178e16e..25d3ccec72 100644 --- a/src/components/FeedItem.vue +++ b/src/components/FeedItem.vue @@ -1,25 +1,29 @@ + + diff --git a/src/components/Starred.vue b/src/components/Starred.vue index b35e472d1a..fee219f796 100644 --- a/src/components/Starred.vue +++ b/src/components/Starred.vue @@ -1,6 +1,9 @@