2021-11-06 02:24:02 +01:00
|
|
|
export const state = () => ({
|
2022-02-09 18:19:02 +01:00
|
|
|
isMobile: false,
|
|
|
|
isMobileLandscape: false,
|
2021-11-27 23:01:53 +01:00
|
|
|
showBatchUserCollectionModal: false,
|
2021-11-07 02:31:46 +01:00
|
|
|
showUserCollectionsModal: false,
|
|
|
|
showEditCollectionModal: false,
|
2022-04-23 02:31:11 +02:00
|
|
|
showEditPodcastEpisode: false,
|
2022-05-28 18:38:51 +02:00
|
|
|
showViewPodcastEpisodeModal: false,
|
2022-05-09 01:21:46 +02:00
|
|
|
showEditAuthorModal: false,
|
2022-04-23 02:31:11 +02:00
|
|
|
selectedEpisode: null,
|
2021-11-28 03:11:35 +01:00
|
|
|
selectedCollection: null,
|
2022-05-09 01:21:46 +02:00
|
|
|
selectedAuthor: null,
|
2022-02-23 00:33:55 +01:00
|
|
|
isCasting: false, // Actively casting
|
2022-06-17 10:26:10 +02:00
|
|
|
isChromecastInitialized: false, // Script loaded
|
|
|
|
dateFormats: [
|
|
|
|
{
|
|
|
|
text: 'MM/DD/YYYY',
|
|
|
|
value: 'MM/dd/yyyy'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'DD/MM/YYYY',
|
|
|
|
value: 'dd/MM/yyyy'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'YYYY-MM-DD',
|
|
|
|
value: 'yyyy-MM-dd'
|
|
|
|
}
|
|
|
|
]
|
2021-11-06 02:24:02 +01:00
|
|
|
})
|
|
|
|
|
2022-03-14 01:34:31 +01:00
|
|
|
export const getters = {
|
|
|
|
getLibraryItemCoverSrc: (state, getters, rootState, rootGetters) => (libraryItem, placeholder = '/book_placeholder.jpg') => {
|
|
|
|
if (!libraryItem) return placeholder
|
|
|
|
var media = libraryItem.media
|
|
|
|
if (!media || !media.coverPath || media.coverPath === placeholder) return placeholder
|
|
|
|
|
|
|
|
// Absolute URL covers (should no longer be used)
|
|
|
|
if (media.coverPath.startsWith('http:') || media.coverPath.startsWith('https:')) return media.coverPath
|
|
|
|
|
|
|
|
var userToken = rootGetters['user/getToken']
|
|
|
|
var lastUpdate = libraryItem.updatedAt || Date.now()
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'production') { // Testing
|
|
|
|
return `http://localhost:3333/api/items/${libraryItem.id}/cover?token=${userToken}&ts=${lastUpdate}`
|
|
|
|
}
|
|
|
|
return `/api/items/${libraryItem.id}/cover?token=${userToken}&ts=${lastUpdate}`
|
|
|
|
}
|
|
|
|
}
|
2021-11-06 02:24:02 +01:00
|
|
|
|
|
|
|
export const mutations = {
|
2022-02-09 18:19:02 +01:00
|
|
|
updateWindowSize(state, { width, height }) {
|
2022-02-11 15:50:28 +01:00
|
|
|
state.isMobile = width < 640 || height < 640
|
2022-02-09 18:19:02 +01:00
|
|
|
state.isMobileLandscape = state.isMobile && height > width
|
|
|
|
},
|
2021-11-06 02:24:02 +01:00
|
|
|
setShowUserCollectionsModal(state, val) {
|
2021-11-27 23:01:53 +01:00
|
|
|
state.showBatchUserCollectionModal = false
|
|
|
|
state.showUserCollectionsModal = val
|
|
|
|
},
|
|
|
|
setShowBatchUserCollectionsModal(state, val) {
|
|
|
|
state.showBatchUserCollectionModal = true
|
2021-11-06 02:24:02 +01:00
|
|
|
state.showUserCollectionsModal = val
|
2021-11-07 02:31:46 +01:00
|
|
|
},
|
|
|
|
setShowEditCollectionModal(state, val) {
|
|
|
|
state.showEditCollectionModal = val
|
|
|
|
},
|
2022-04-23 02:31:11 +02:00
|
|
|
setShowEditPodcastEpisodeModal(state, val) {
|
|
|
|
state.showEditPodcastEpisode = val
|
|
|
|
},
|
2022-05-28 18:38:51 +02:00
|
|
|
setShowViewPodcastEpisodeModal(state, val) {
|
|
|
|
state.showViewPodcastEpisodeModal = val
|
|
|
|
},
|
2021-11-07 02:31:46 +01:00
|
|
|
setEditCollection(state, collection) {
|
|
|
|
state.selectedCollection = collection
|
|
|
|
state.showEditCollectionModal = true
|
2021-11-28 03:11:35 +01:00
|
|
|
},
|
2022-04-23 02:31:11 +02:00
|
|
|
setSelectedEpisode(state, episode) {
|
|
|
|
state.selectedEpisode = episode
|
|
|
|
},
|
2022-05-09 01:21:46 +02:00
|
|
|
showEditAuthorModal(state, author) {
|
|
|
|
state.selectedAuthor = author
|
|
|
|
state.showEditAuthorModal = true
|
|
|
|
},
|
|
|
|
setShowEditAuthorModal(state, val) {
|
|
|
|
state.showEditAuthorModal = val
|
|
|
|
},
|
|
|
|
setSelectedAuthor(state, author) {
|
|
|
|
state.selectedAuthor = author
|
|
|
|
},
|
2022-02-23 00:33:55 +01:00
|
|
|
setChromecastInitialized(state, val) {
|
|
|
|
state.isChromecastInitialized = val
|
|
|
|
},
|
|
|
|
setCasting(state, val) {
|
|
|
|
state.isCasting = val
|
2021-11-06 02:24:02 +01:00
|
|
|
}
|
|
|
|
}
|