1+ import { del , set } from 'vue-demi'
2+
13import StoreData from './interfaces/StoreData'
24
35import { MutationTree } from 'vuex/types'
@@ -13,9 +15,7 @@ export const mutations: MutationTree<State> = {
1315 * @param uri URI of the object that is being fetched
1416 */
1517 addEmpty ( state : State , uri : string ) : void {
16- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17- // @ts -ignore
18- state [ uri ] = { _meta : { self : uri , loading : true } }
18+ set ( state , uri , { _meta : { self : uri , loading : true } } )
1919 } ,
2020 /**
2121 * Adds entities loaded from the API to the Vuex store.
@@ -24,12 +24,10 @@ export const mutations: MutationTree<State> = {
2424 */
2525 add ( state : State , data : Record < string , unknown > ) : void {
2626 Object . keys ( data ) . forEach ( uri => {
27- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28- // @ts -ignore
29- state [ uri ] = data [ uri ]
27+ set ( state , uri , data [ uri ] )
3028
31- state [ uri ] . _meta . loading = false
32- state [ uri ] . _meta . reloading = false
29+ set ( state [ uri ] . _meta , ' loading' , false )
30+ set ( state [ uri ] . _meta , ' reloading' , false )
3331 } )
3432 } ,
3533 /**
@@ -38,23 +36,23 @@ export const mutations: MutationTree<State> = {
3836 * @param uri URI of the entity that is currently being reloaded
3937 */
4038 reloading ( state : State , uri : string ) : void {
41- if ( state [ uri ] ) state [ uri ] . _meta . reloading = true
39+ if ( state [ uri ] ) set ( state [ uri ] . _meta , ' reloading' , true )
4240 } ,
4341 /**
4442 * Marks a single entity in the Vuex store as normal again, after it has been marked as reloading before.
4543 * @param state Vuex state
4644 * @param uri URI of the entity that is currently being reloaded
4745 */
4846 reloadingFailed ( state : State , uri : string ) : void {
49- if ( state [ uri ] ) state [ uri ] . _meta . reloading = false
47+ if ( state [ uri ] ) set ( state [ uri ] . _meta , ' reloading' , false )
5048 } ,
5149 /**
5250 * Removes a single entity from the Vuex store.
5351 * @param state Vuex state
5452 * @param uri URI of the entity to be removed
5553 */
5654 purge ( state : State , uri : string ) : void {
57- delete state [ uri ]
55+ del ( state , uri )
5856 } ,
5957 /**
6058 * Removes all entities from the Vuex store.
@@ -63,7 +61,7 @@ export const mutations: MutationTree<State> = {
6361 */
6462 purgeAll ( state : State ) : void {
6563 Object . keys ( state ) . forEach ( uri => {
66- delete state [ uri ]
64+ del ( state , uri )
6765 } )
6866 } ,
6967 /**
@@ -72,15 +70,15 @@ export const mutations: MutationTree<State> = {
7270 * @param uri URI of the entity that is currently being deleted
7371 */
7472 deleting ( state : State , uri : string ) : void {
75- if ( state [ uri ] ) state [ uri ] . _meta . deleting = true
73+ if ( state [ uri ] ) set ( state [ uri ] . _meta , ' deleting' , true )
7674 } ,
7775 /**
7876 * Marks a single entity in the Vuex store as normal again, after it has been marked as deleting before.
7977 * @param state Vuex state
8078 * @param uri URI of the entity that failed to be deleted
8179 */
8280 deletingFailed ( state : State , uri : string ) : void {
83- if ( state [ uri ] ) state [ uri ] . _meta . deleting = false
81+ if ( state [ uri ] ) set ( state [ uri ] . _meta , ' deleting' , false )
8482 }
8583}
8684
0 commit comments