diff options
author | Devlin Junker <devlin.junker@gmail.com> | 2022-12-03 15:40:06 -0800 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2022-12-06 14:57:20 +0100 |
commit | 2c32ea05f0a0f266e36075e702ee293d7834bf62 (patch) | |
tree | 8cf87a4a051af892f76213182471df09de7674e9 /src/store | |
parent | 4899be32e3f6065297f95e0ccc42e97efbec545b (diff) |
start on state/store tests
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/feed.ts | 19 | ||||
-rw-r--r-- | src/store/folder.ts | 19 |
2 files changed, 17 insertions, 21 deletions
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 = [] |