Implement reordering with optimistic updates
This commit is contained in:
24
app/stores/use-current-playlist-store.ts
Normal file
24
app/stores/use-current-playlist-store.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { PlaylistReadResponse } from '~/composeables/api/models'
|
||||
|
||||
export const useCurrentPlaylistStore = defineStore('current-playlist', {
|
||||
state: () => ({
|
||||
id: -1,
|
||||
ownerId: -1,
|
||||
title: '',
|
||||
createdAt: '',
|
||||
updatedAt: '',
|
||||
}),
|
||||
getters: {
|
||||
getId: (state) => state.id * 2,
|
||||
},
|
||||
actions: {
|
||||
load(response: PlaylistReadResponse) {
|
||||
this.id = response.id || -1;
|
||||
this.ownerId = response.ownerId || -1;
|
||||
this.title = response.title || '';
|
||||
this.createdAt = response.createdAt || '';
|
||||
this.updatedAt = response.updatedAt || '';
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user