Browse Source

Merge branch 'staging' of https://github.com/Musare/Musare into staging

Kristian Vos 3 years ago
parent
commit
98ced961a5

+ 1 - 1
backend/logic/actions/songs.js

@@ -452,7 +452,7 @@ export default {
 		async.waterfall(
 			[
 				next => {
-					SongsModule.runJob("CREATE_SONG", { song: newSong }, this)
+					SongsModule.runJob("CREATE_SONG", { song: newSong, userId: session.userId }, this)
 						.then(song => next(null, song))
 						.catch(next);
 				}

+ 22 - 1
backend/logic/songs.js

@@ -289,6 +289,7 @@ class _SongsModule extends CoreClass {
 	 *
 	 * @param {object} payload - an object containing the payload
 	 * @param {string} payload.song - the song object
+	 * @param {string} payload.userId - the user id of the person requesting the song
 	 * @returns {Promise} - returns a promise (resolve, reject)
 	 */
 	CREATE_SONG(payload) {
@@ -296,7 +297,27 @@ class _SongsModule extends CoreClass {
 			async.waterfall(
 				[
 					next => {
-						const song = new SongsModule.SongModel(payload.song);
+						DBModule.runJob("GET_MODEL", { modelName: "user" }, this)
+							.then(UserModel => {
+								UserModel.findOne(
+									{ _id: payload.userId },
+									{ "preferences.anonymousSongRequests": 1 },
+									next
+								);
+							})
+							.catch(next);
+					},
+
+					(user, next) => {
+						const song = new SongsModule.SongModel({
+							...payload.song,
+							requestedBy: user.preferences.anonymousSongRequests ? null : payload.userId,
+							requestedAt: Date.now()
+						});
+						if (song.verified) {
+							song.verifiedBy = payload.userId;
+							song.verifiedAt = Date.now();
+						}
 						song.save({ validateBeforeSave: true }, err => {
 							if (err) return next(err, song);
 							return next(null, song);

+ 5 - 3
backend/logic/stations.js

@@ -479,14 +479,13 @@ class _StationsModule extends CoreClass {
 					},
 
 					(playlist, station, next) => {
-						const songs = playlist.songs.filter(song => song._id !== station.currentSong._id);
 						if (station.playMode === "random") {
-							UtilsModule.runJob("SHUFFLE", { array: songs }, this)
+							UtilsModule.runJob("SHUFFLE", { array: playlist.songs }, this)
 								.then(response => {
 									next(null, response.array, station);
 								})
 								.catch(next);
-						} else next(null, songs, station);
+						} else next(null, playlist.songs, station);
 					},
 
 					(_playlistSongs, station, next) => {
@@ -503,6 +502,9 @@ class _StationsModule extends CoreClass {
 						const songsToAdd = [];
 						let lastSongAdded = null;
 
+						if (station.currentSong && station.currentSong.youtubeId)
+							currentYoutubeIds.push(station.currentSong.youtubeId);
+
 						playlistSongs.every(song => {
 							if (
 								songsToAdd.length < songsStillNeeded &&

+ 14 - 13
frontend/src/components/SongItem.vue

@@ -11,19 +11,12 @@
 				<h6 v-if="header">{{ header }}</h6>
 				<div class="song-title">
 					<h4
-						class="item-title"
-						:style="
-							!song.artists ||
-							(song.artists && song.artists.length < 1)
-								? {
-										display: '-webkit-inline-box',
-										fontSize: '16px',
-										whiteSpace: 'normal',
-										'-webkit-box-orient': 'vertical',
-										'-webkit-line-clamp': 2
-								  }
-								: null
-						"
+						:class="{
+							'item-title': true,
+							'no-artists':
+								!song.artists ||
+								(song.artists && song.artists.length < 1)
+						}"
 						:title="song.title"
 					>
 						{{ song.title }}
@@ -366,6 +359,14 @@ export default {
 			.verified-song {
 				margin-left: 5px;
 			}
+
+			.item-title.no-artists {
+				display: -webkit-inline-box;
+				font-size: 16px;
+				white-space: normal;
+				-webkit-box-orient: vertical;
+				-webkit-line-clamp: 2;
+			}
 		}
 
 		.song-request-time {

+ 2 - 2
frontend/src/components/layout/MainHeader.vue

@@ -39,12 +39,12 @@
 					}"
 					:content="`${
 						localNightmode ? 'Disable' : 'Enable'
-					} Night Mode`"
+					} Nightmode`"
 					v-tippy
 				>
 					{{ localNightmode ? "dark_mode" : "light_mode" }}
 				</span>
-				<span class="night-mode-label">Toggle Night Mode</span>
+				<span class="night-mode-label">Toggle Nightmode</span>
 			</div>
 			<span v-if="loggedIn" class="grouped">
 				<router-link

+ 0 - 4
frontend/src/components/modals/EditSong/index.vue

@@ -49,10 +49,6 @@
 								width="530"
 								@click="setTrackPosition($event)"
 							/>
-							<div id="playerTrack">
-								<div class="skip-duration"></div>
-								<div class="real-duration"></div>
-							</div>
 							<div class="player-footer">
 								<div class="player-footer-left">
 									<div class="control has-addons">

+ 5 - 7
frontend/src/components/modals/EditSongs.vue

@@ -290,6 +290,11 @@ export default {
 				prefill: this.songPrefillData[song._id]
 			});
 			this.currentSong = song;
+			if (
+				this.$refs[`edit-songs-item-${song._id}`] &&
+				this.$refs[`edit-songs-item-${song._id}`][0]
+			)
+				this.$refs[`edit-songs-item-${song._id}`][0].scrollIntoView();
 		},
 		editNextSong() {
 			const currentlyEditingSongIndex = this.filteredEditingItemIndex;
@@ -308,13 +313,6 @@ export default {
 			if (newEditingSongIndex > -1) {
 				const nextSong = this.filteredItems[newEditingSongIndex].song;
 				this.pickSong(nextSong);
-				if (
-					this.$refs[`edit-songs-item-${nextSong._id}`] &&
-					this.$refs[`edit-songs-item-${nextSong._id}`][0]
-				)
-					this.$refs[
-						`edit-songs-item-${nextSong._id}`
-					][0].scrollIntoView();
 			}
 		},
 		toggleFlag(songIndex = null) {