diff options
author | Devlin Junker <devlin.junker@gmail.com> | 2023-10-05 10:27:26 -0700 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2023-10-06 08:18:41 +0200 |
commit | 991facf2ee638713d2f2ef8b5197f32742d01804 (patch) | |
tree | f7da3576d44a76ce76ab28ca66d70d861d4aa24c /src | |
parent | 498c001bd35553d68b9332a971fd22afccdfdefa (diff) |
tests and some cleanup
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/App.vue | 1 | ||||
-rw-r--r-- | src/main.js | 24 | ||||
-rw-r--r-- | src/store/app.ts | 2 | ||||
-rw-r--r-- | src/store/feed.ts | 8 | ||||
-rw-r--r-- | src/store/folder.ts | 8 | ||||
-rw-r--r-- | src/store/index.ts | 13 |
6 files changed, 31 insertions, 25 deletions
diff --git a/src/App.vue b/src/App.vue index cd1e3e06d..9f877a6c5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -69,7 +69,6 @@ export default Vue.extend({ }, stopVideo() { const videoElements = document.getElementsByTagName('video') - for (let i = 0; i < videoElements.length; i++) { videoElements[i].pause() } diff --git a/src/main.js b/src/main.js index 98a56a743..9a70d470f 100644 --- a/src/main.js +++ b/src/main.js @@ -21,19 +21,23 @@ Vue.directive('tooltip', Tooltip) const store = new Store(mainStore) -axios.interceptors.response(undefined /* onSuccessCallback is intentionally undefined */, - // Any status codes that falls outside the range of 2xx cause this function to trigger - function(error) { +/** + * Handles errors returned during application runtime + * + * @param {Error} error Error thrown + * @return Promise<Error> + */ +const handleErrors = function(error) { + store.commit(MUTATIONS.SET_ERROR, error) + return Promise.reject(error) +} - store.commit(MUTATIONS.SET_ERROR, error) - return Promise.reject(error) - }, +axios.interceptors.response.use(undefined /* onSuccessCallback is intentionally undefined (triggers on 2xx responses) */, + // Any status codes that falls outside the range of 2xx cause this function to trigger + handleErrors, ) -Vue.config.errorHandler = function(err) { - store.commit(MUTATIONS.SET_ERROR, err) -} - +Vue.config.errorHandler = handleErrors export default new Vue({ router, store, diff --git a/src/store/app.ts b/src/store/app.ts index 5b7f4c8dc..2b470c946 100644 --- a/src/store/app.ts +++ b/src/store/app.ts @@ -4,7 +4,7 @@ export const APPLICATION_ACTION_TYPES = { SET_ERROR_MESSAGE: 'SET_ERROR_MESSAGE', } -type AppInfoState = { +export type AppInfoState = { error?: Error; } diff --git a/src/store/feed.ts b/src/store/feed.ts index 9fea76a72..2a62ff5fe 100644 --- a/src/store/feed.ts +++ b/src/store/feed.ts @@ -23,12 +23,16 @@ export const FEED_ACTION_TYPES = { FEED_DELETE: 'FEED_DELETE', } -const state = { +export type FeedState = { + feeds: Feed[] +} + +const state: FeedState = { feeds: [], } const getters = { - feeds(state: AppState) { + feeds(state: FeedState) { return state.feeds }, } diff --git a/src/store/folder.ts b/src/store/folder.ts index 680eab097..d125c5b99 100644 --- a/src/store/folder.ts +++ b/src/store/folder.ts @@ -14,12 +14,16 @@ export const FOLDER_ACTION_TYPES = { FOLDER_SET_NAME: 'FOLDER_SET_NAME', } -const state = { +export type FolderState = { + folders: Folder[] +} + +const state: FolderState = { folders: [], } const getters = { - folders(state: AppState) { + folders(state: FolderState) { return state.folders }, } diff --git a/src/store/index.ts b/src/store/index.ts index 2eea645d9..44f933740 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,10 +1,8 @@ -import { Folder } from '../types/Folder' -import { Feed } from '../types/Feed' -import feeds, { FEED_ACTION_TYPES } from './feed' -import folders, { FOLDER_ACTION_TYPES } from './folder' import { FOLDER_MUTATION_TYPES, FEED_MUTATION_TYPES, FEED_ITEM_MUTATION_TYPES, APPLICATION_MUTATION_TYPES } from '../types/MutationTypes' +import feeds, { FEED_ACTION_TYPES, FeedState } from './feed' +import folders, { FOLDER_ACTION_TYPES, FolderState } from './folder' import items, { FEED_ITEM_ACTION_TYPES, ItemState } from './item' -import app, { APPLICATION_ACTION_TYPES } from './app' +import app, { APPLICATION_ACTION_TYPES, AppInfoState } from './app' export const MUTATIONS = { ...APPLICATION_MUTATION_TYPES, @@ -20,10 +18,7 @@ export const ACTIONS = { ...FEED_ITEM_ACTION_TYPES, } -export type AppState = { - feeds: Feed[]; - folders: Folder[]; -} & ItemState; +export type AppState = FolderState & FeedState & ItemState & AppInfoState; type Func = (name: string, value: unknown) => void; export type ActionParams = { commit: Func; dispatch: Func; state: AppState }; |