@@ -57,14 +57,14 @@ export default {
computed: {
show: {
get() {
- return this.$store.state.globals.showUserCollectionsModal
+ return this.$store.state.globals.showCollectionsModal
},
set(val) {
- this.$store.commit('globals/setShowUserCollectionsModal', val)
+ this.$store.commit('globals/setShowCollectionsModal', val)
}
},
title() {
- if (this.showBatchUserCollectionModal) {
+ if (this.showBatchCollectionModal) {
return this.$getString('MessageItemsSelected', [this.selectedBookIds.length])
}
return this.selectedLibraryItem ? this.selectedLibraryItem.media.metadata.title : ''
@@ -85,7 +85,7 @@ export default {
return this.collections
.map((c) => {
var includesBook = false
- if (this.showBatchUserCollectionModal) {
+ if (this.showBatchCollectionModal) {
// Only show collection added if all books are in the collection
var collectionBookIds = c.books.map((b) => b.id)
includesBook = !this.selectedBookIds.find((id) => !collectionBookIds.includes(id))
@@ -100,8 +100,8 @@ export default {
})
.sort((a, b) => (a.isBookIncluded ? -1 : 1))
},
- showBatchUserCollectionModal() {
- return this.$store.state.globals.showBatchUserCollectionModal
+ showBatchCollectionModal() {
+ return this.$store.state.globals.showBatchCollectionModal
},
selectedBookIds() {
return this.$store.state.selectedLibraryItems || []
@@ -112,13 +112,13 @@ export default {
},
methods: {
loadCollections() {
- this.$store.dispatch('user/loadUserCollections')
+ this.$store.dispatch('user/loadCollections')
},
removeFromCollection(collection) {
if (!this.selectedLibraryItemId && !this.selectedBookIds.length) return
this.processing = true
- if (this.showBatchUserCollectionModal) {
+ if (this.showBatchCollectionModal) {
// BATCH Remove books
this.$axios
.$post(`/api/collections/${collection.id}/batch/remove`, { books: this.selectedBookIds })
@@ -152,7 +152,7 @@ export default {
if (!this.selectedLibraryItemId && !this.selectedBookIds.length) return
this.processing = true
- if (this.showBatchUserCollectionModal) {
+ if (this.showBatchCollectionModal) {
// BATCH Remove books
this.$axios
.$post(`/api/collections/${collection.id}/batch/add`, { books: this.selectedBookIds })
@@ -189,7 +189,7 @@ export default {
}
this.processing = true
- var books = this.showBatchUserCollectionModal ? this.selectedBookIds : [this.selectedLibraryItemId]
+ var books = this.showBatchCollectionModal ? this.selectedBookIds : [this.selectedLibraryItemId]
var newCollection = {
books: books,
libraryId: this.currentLibraryId,
diff --git a/client/layouts/default.vue b/client/layouts/default.vue
index 1e13f5ed..828410e7 100644
--- a/client/layouts/default.vue
+++ b/client/layouts/default.vue
@@ -10,7 +10,7 @@
-
+
diff --git a/client/pages/item/_id/index.vue b/client/pages/item/_id/index.vue
index f7c3f8f7..dbd0856a 100644
--- a/client/pages/item/_id/index.vue
+++ b/client/pages/item/_id/index.vue
@@ -582,7 +582,7 @@ export default {
},
collectionsClick() {
this.$store.commit('setSelectedLibraryItem', this.libraryItem)
- this.$store.commit('globals/setShowUserCollectionsModal', true)
+ this.$store.commit('globals/setShowCollectionsModal', true)
},
clickRSSFeed() {
this.showRssFeedModal = true
diff --git a/client/store/globals.js b/client/store/globals.js
index 54add6b6..cf1b5672 100644
--- a/client/store/globals.js
+++ b/client/store/globals.js
@@ -1,8 +1,8 @@
export const state = () => ({
isMobile: false,
isMobileLandscape: false,
- showBatchUserCollectionModal: false,
- showUserCollectionsModal: false,
+ showBatchCollectionModal: false,
+ showCollectionsModal: false,
showEditCollectionModal: false,
showEditPodcastEpisode: false,
showViewPodcastEpisodeModal: false,
@@ -68,13 +68,13 @@ export const mutations = {
state.isMobile = width < 640 || height < 640
state.isMobileLandscape = state.isMobile && height > width
},
- setShowUserCollectionsModal(state, val) {
- state.showBatchUserCollectionModal = false
- state.showUserCollectionsModal = val
+ setShowCollectionsModal(state, val) {
+ state.showBatchCollectionModal = false
+ state.showCollectionsModal = val
},
- setShowBatchUserCollectionsModal(state, val) {
- state.showBatchUserCollectionModal = true
- state.showUserCollectionsModal = val
+ setShowBatchCollectionsModal(state, val) {
+ state.showBatchCollectionModal = true
+ state.showCollectionsModal = val
},
setShowEditCollectionModal(state, val) {
state.showEditCollectionModal = val
diff --git a/client/store/user.js b/client/store/user.js
index 90f17b2b..852b0abb 100644
--- a/client/store/user.js
+++ b/client/store/user.js
@@ -114,7 +114,7 @@ export const actions = {
return false
})
},
- loadUserCollections({ state, commit }) {
+ loadCollections({ state, commit }) {
if (state.collectionsLoaded) {
console.log('Collections already loaded')
return state.collections
diff --git a/server/Db.js b/server/Db.js
index bc88ca3e..96a859f1 100644
--- a/server/Db.js
+++ b/server/Db.js
@@ -4,7 +4,7 @@ const Logger = require('./Logger')
const { version } = require('../package.json')
const LibraryItem = require('./objects/LibraryItem')
const User = require('./objects/user/User')
-const UserCollection = require('./objects/UserCollection')
+const Collection = require('./objects/Collection')
const Library = require('./objects/Library')
const Author = require('./objects/entities/Author')
const Series = require('./objects/entities/Series')
@@ -180,7 +180,7 @@ class Db {
}
})
var p5 = this.collectionsDb.select(() => true).then((results) => {
- this.collections = results.data.map(l => new UserCollection(l))
+ this.collections = results.data.map(l => new Collection(l))
Logger.info(`[DB] ${this.collections.length} Collections Loaded`)
})
var p6 = this.authorsDb.select(() => true).then((results) => {
diff --git a/server/controllers/CollectionController.js b/server/controllers/CollectionController.js
index d3ae4917..00a8687c 100644
--- a/server/controllers/CollectionController.js
+++ b/server/controllers/CollectionController.js
@@ -1,11 +1,11 @@
const Logger = require('../Logger')
-const UserCollection = require('../objects/UserCollection')
+const Collection = require('../objects/Collection')
class CollectionController {
constructor() { }
async create(req, res) {
- var newCollection = new UserCollection()
+ var newCollection = new Collection()
req.body.userId = req.user.id
var success = newCollection.setData(req.body)
if (!success) {
diff --git a/server/controllers/UserController.js b/server/controllers/UserController.js
index 662afcbf..196f7d4d 100644
--- a/server/controllers/UserController.js
+++ b/server/controllers/UserController.js
@@ -105,13 +105,6 @@ class UserController {
}
var user = req.reqUser
- // delete user collections
- var userCollections = this.db.collections.filter(c => c.userId === user.id)
- var collectionsToRemove = userCollections.map(uc => uc.id)
- for (let i = 0; i < collectionsToRemove.length; i++) {
- await this.db.removeEntity('collection', collectionsToRemove[i])
- }
-
// Todo: check if user is logged in and cancel streams
var userJson = user.toJSONForBrowser()
diff --git a/server/objects/UserCollection.js b/server/objects/Collection.js
similarity index 98%
rename from server/objects/UserCollection.js
rename to server/objects/Collection.js
index b3151f78..97a8ce37 100644
--- a/server/objects/UserCollection.js
+++ b/server/objects/Collection.js
@@ -1,7 +1,7 @@
const Logger = require('../Logger')
const { getId } = require('../utils/index')
-class UserCollection {
+class Collection {
constructor(collection) {
this.id = null
this.libraryId = null
@@ -105,4 +105,4 @@ class UserCollection {
return hasUpdates
}
}
-module.exports = UserCollection
\ No newline at end of file
+module.exports = Collection
\ No newline at end of file