summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDevlin Junker <devlin.junker@gmail.com>2022-12-03 15:40:06 -0800
committerBenjamin Brahmer <info@b-brahmer.de>2022-12-06 14:57:20 +0100
commit2c32ea05f0a0f266e36075e702ee293d7834bf62 (patch)
tree8cf87a4a051af892f76213182471df09de7674e9 /src
parent4899be32e3f6065297f95e0ccc42e97efbec545b (diff)
start on state/store tests
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/AddFeed.vue4
-rw-r--r--src/components/Explore.vue2
-rw-r--r--src/components/Sidebar.vue16
-rw-r--r--src/store/feed.ts19
-rw-r--r--src/store/folder.ts19
5 files changed, 28 insertions, 32 deletions
diff --git a/src/components/AddFeed.vue b/src/components/AddFeed.vue
index 462ab77d1..af5d75937 100644
--- a/src/components/AddFeed.vue
+++ b/src/components/AddFeed.vue
@@ -115,7 +115,7 @@ import NcMultiselect from '@nextcloud/vue/dist/Components/NcMultiselect.js'
import { Folder } from '../types/Folder'
import { Feed } from '../types/Feed'
-import { ACTIONS, AppState } from '../store'
+import { ACTIONS } from '../store'
type AddFeedState = {
folder: Folder;
@@ -142,7 +142,7 @@ export default Vue.extend({
},
data: (): AddFeedState => {
return {
- folder: { name: '' } as any,
+ folder: { name: '' } as Folder,
autoDiscover: true,
createNewFolder: false,
withBasicAuth: false,
diff --git a/src/components/Explore.vue b/src/components/Explore.vue
index e909101f7..067dd61b3 100644
--- a/src/components/Explore.vue
+++ b/src/components/Explore.vue
@@ -50,7 +50,7 @@ const ExploreComponent = Vue.extend({
},
data: () => {
const exploreSites: ExploreSite[] = []
- const feed: Feed = {} as any
+ const feed: Feed = {} as Feed
const showAddFeed = false
return {
diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue
index cd88369ee..c51ea16ac 100644
--- a/src/components/Sidebar.vue
+++ b/src/components/Sidebar.vue
@@ -129,7 +129,7 @@
<script lang="ts">
-import Vuex from 'vuex'
+import { mapState } from 'vuex'
import Vue from 'vue'
import NcAppNavigation from '@nextcloud/vue/dist/Components/NcAppNavigation.js'
@@ -148,9 +148,10 @@ import AddFeed from './AddFeed.vue'
import { Folder } from '../types/Folder'
import { Feed } from '../types/Feed'
-const SideBarState: any = {
- topLevelNav(localState: any, state: AppState): any[] {
- let navItems: any[] = state.feeds.filter((feed: Feed) => {
+const SideBarState = {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ topLevelNav(localState: any, state: AppState): (Feed | Folder)[] {
+ let navItems: (Feed | Folder)[] = state.feeds.filter((feed: Feed) => {
return feed.folderId === undefined || feed.folderId === null
})
navItems = navItems.concat(state.folders)
@@ -177,11 +178,11 @@ export default Vue.extend({
}
},
computed: {
- ...Vuex.mapState(['feeds', 'folders']),
- ...Vuex.mapState(SideBarState),
+ ...mapState(['feeds', 'folders']),
+ ...mapState(SideBarState),
},
created() {
- // TODO: ?
+ // TODO: init?
},
methods: {
newFolder(value: string) {
@@ -191,7 +192,6 @@ export default Vue.extend({
},
deleteFolder(folder: Folder) {
this.$store.dispatch(ACTIONS.DELETE_FOLDER, { folder })
- // TODO: Reload
},
showShowAddFeed() {
this.showAddFeed = true
diff --git a/src/store/feed.ts b/src/store/feed.ts
index a74b7c9e4..e39907f38 100644
--- a/src/store/feed.ts
+++ b/src/store/feed.ts
@@ -4,15 +4,15 @@ import { generateUrl } from '@nextcloud/router'
import { ActionParams, AppState } from '../store'
import { Feed } from '../types/Feed'
-export const FEED_MUTATION_TYPES = {
- SET_FEEDS: 'SET_FEEDS',
-}
-
export const FEED_ACTION_TYPES = {
ADD_FEED: 'ADD_FEED',
FETCH_FEEDS: 'FETCH_FEEDS',
}
+export const FEED_MUTATION_TYPES = {
+ SET_FEEDS: 'SET_FEEDS',
+}
+
const state = {
feeds: [],
}
@@ -33,8 +33,7 @@ export const actions = {
commit(FEED_MUTATION_TYPES.SET_FEEDS, feeds.data.feeds)
},
- [FEED_ACTION_TYPES.ADD_FEED]({ commit }: ActionParams, { feedReq }: { feedReq: { url: string; folder?: { id: number } } }) {
- console.log(feedReq)
+ async [FEED_ACTION_TYPES.ADD_FEED]({ commit }: ActionParams, { feedReq }: { feedReq: { url: string; folder?: { id: number } } }) {
let url = feedReq.url.trim()
if (!url.startsWith('http')) {
url = 'https://' + url
@@ -51,22 +50,22 @@ export const actions = {
folderId: feedReq.folder?.id || 0,
title: undefined,
unreadCount: 0,
- autoDiscover: undefined, // TODO
+ autoDiscover: undefined, // TODO: autodiscover?
}
// this.add(feed);
// this.updateFolderCache();
- axios.post(feedUrl, {
+ await axios.post(feedUrl, {
url: feed.url,
parentFolderId: feed.folderId,
title: null,
user: null,
password: null,
fullDiscover: feed.autoDiscover,
- }).then(() => {
- commit('addFeed', feed)
})
+
+ commit('addFeed', feed)
},
}
diff --git a/src/store/folder.ts b/src/store/folder.ts
index 3a46e755b..70a05c4ed 100644
--- a/src/store/folder.ts
+++ b/src/store/folder.ts
@@ -4,17 +4,17 @@ import { generateUrl } from '@nextcloud/router'
import { AppState, ActionParams } from '../store'
import { Folder } from '../types/Folder'
-export const FOLDER_MUTATION_TYPES = {
- SET_FOLDERS: 'SET_FOLDERS',
- DELETE_FOLDER: 'DELETE_FOLDER',
-}
-
export const FOLDER_ACTION_TYPES = {
FETCH_FOLDERS: 'FETCH_FOLDERS',
ADD_FOLDERS: 'ADD_FOLDER',
DELETE_FOLDER: 'DELETE_FOLDER',
}
+export const FOLDER_MUTATION_TYPES = {
+ SET_FOLDERS: 'SET_FOLDERS',
+ DELETE_FOLDER: 'DELETE_FOLDER',
+}
+
const state = {
folders: [],
}
@@ -35,11 +35,9 @@ export const actions = {
commit(FOLDER_MUTATION_TYPES.SET_FOLDERS, folders.data.folders)
},
- [FOLDER_ACTION_TYPES.ADD_FOLDERS]({ commit }: ActionParams, { folder }: { folder: Folder}) {
- console.log(folder)
- axios.post(folderUrl, { folderName: folder.name }).then(
- response => commit(FOLDER_MUTATION_TYPES.SET_FOLDERS, response.data.folders),
- )
+ async [FOLDER_ACTION_TYPES.ADD_FOLDERS]({ commit }: ActionParams, { folder }: { folder: Folder}) {
+ const response = await axios.post(folderUrl, { folderName: folder.name })
+ commit(FOLDER_MUTATION_TYPES.SET_FOLDERS, response.data.folders)
},
[FOLDER_ACTION_TYPES.DELETE_FOLDER]({ commit }: ActionParams, { folder }: { folder: Folder}) {
/**
@@ -65,7 +63,6 @@ export const actions = {
export const mutations = {
[FOLDER_MUTATION_TYPES.SET_FOLDERS](state: AppState, folders: Folder[]) {
- console.log(folders)
folders.forEach(it => {
it.feedCount = 0
it.feeds = []