Browse Source

refactor: allow djs in official stations, some small fixes/changes

Kristian Vos 1 year ago
parent
commit
b2c22bb4b3

+ 1 - 1
backend/logic/db/schemas/stationHistory.js

@@ -16,7 +16,7 @@ export default {
 			verified: { type: Boolean }
 		},
 		skippedAt: { type: Date },
-		skipReason: { type: String, enum: ["natural", "force_skip", "vote_skip"] }
+		skipReason: { type: String, enum: ["natural", "force_skip", "vote_skip", "other"] }
 	},
 	documentVersion: { type: Number, default: 1, required: true }
 };

+ 2 - 2
backend/logic/hooks/hasPermission.js

@@ -136,7 +136,7 @@ export const hasPermission = async (permission, session, stationId) => {
 							if (!station) return next("Station not found.");
 							if (station.type === "community" && station.owner === user._id.toString())
 								return next(null, [user.role, "owner"]);
-							if (station.type === "community" && station.djs.find(dj => dj === user._id.toString()))
+							if (station.djs.find(dj => dj === user._id.toString()))
 								return next(null, [user.role, "dj"]);
 							if (user.role === "admin" || user.role === "moderator") return next(null, [user.role]);
 							return next("Invalid permissions.");
@@ -251,7 +251,7 @@ export const getUserPermissions = async (session, stationId) => {
 							if (!station) return next("Station not found.");
 							if (station.type === "community" && station.owner === user._id.toString())
 								return next(null, [user.role, "owner"]);
-							if (station.type === "community" && station.djs.find(dj => dj === user._id.toString()))
+							if (station.djs.find(dj => dj === user._id.toString()))
 								return next(null, [user.role, "dj"]);
 							if (user.role === "admin" || user.role === "moderator") return next(null, [user.role]);
 							return next("Invalid permissions.");

+ 3 - 1
frontend/src/components/PlaylistTabBase.vue

@@ -113,7 +113,8 @@ const {
 } = stationStore;
 
 const showTab = _tab => {
-	tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
+	if (tabs.value[`${_tab}-tab`])
+		tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
 	tab.value = _tab;
 };
 
@@ -306,6 +307,7 @@ onMounted(() => {
 
 		if (
 			autorequestLocalStorageItem &&
+			station.value.requests &&
 			station.value.requests.allowAutorequest &&
 			autoRequest.value.length === 0
 		) {

+ 2 - 1
frontend/src/components/modals/EditPlaylist/index.vue

@@ -62,7 +62,8 @@ const { setPlaylist, clearPlaylist, addSong, removeSong, repositionedSong } =
 const { closeCurrentModal } = useModalsStore();
 
 const showTab = payload => {
-	tabs.value[`${payload}-tab`].scrollIntoView({ block: "nearest" });
+	if (tabs.value[`${payload}-tab`])
+		tabs.value[`${payload}-tab`].scrollIntoView({ block: "nearest" });
 	editPlaylistStore.showTab(payload);
 };
 

+ 2 - 1
frontend/src/components/modals/EditSong/Tabs/Reports.vue

@@ -56,7 +56,8 @@ const sortedByCategory = computed(() => {
 const { resolveReport } = editSongStore;
 
 const showTab = _tab => {
-	tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
+	if (tabs.value[`${_tab}-tab`])
+		tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
 	tab.value = _tab;
 };
 

+ 2 - 9
frontend/src/pages/Home.vue

@@ -560,11 +560,7 @@ onBeforeUnmount(() => {
 												>{{ t("Icons.Home") }}</i
 											>
 											<i
-												v-if="
-													element.type ===
-														'community' &&
-													isDj(element)
-												"
+												v-if="isDj(element)"
 												class="djIcon material-icons"
 												:content="t('UserIsDj')"
 												v-tippy="{ theme: 'info' }"
@@ -831,10 +827,7 @@ onBeforeUnmount(() => {
 										>{{ t("Icons.Home") }}</i
 									>
 									<i
-										v-if="
-											station.type === 'community' &&
-											isDj(station)
-										"
+										v-if="isDj(station)"
 										class="djIcon material-icons"
 										:content="t('UserIsDj')"
 										v-tippy="{ theme: 'info' }"

+ 28 - 38
frontend/src/pages/Station/Sidebar/Users.vue

@@ -72,7 +72,8 @@ const copyToClipboard = async () => {
 };
 
 const showTab = _tab => {
-	tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
+	if (tabs.value[`${_tab}-tab`])
+		tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
 	tab.value = _tab;
 };
 
@@ -135,13 +136,7 @@ onMounted(async () => {
 <template>
 	<div id="users">
 		<div class="tabs-container">
-			<div
-				v-if="
-					hasPermission('stations.update') &&
-					station.type === 'community'
-				"
-				class="tab-selection"
-			>
+			<div v-if="hasPermission('stations.update')" class="tab-selection">
 				<button
 					class="button is-default"
 					:ref="el => (tabs['active-tab'] = el)"
@@ -238,7 +233,6 @@ onMounted(async () => {
 									<button
 										v-if="
 											hasPermission('stations.djs.add') &&
-											station.type === 'community' &&
 											!isDj(user._id) &&
 											!isOwner(user._id)
 										"
@@ -253,9 +247,7 @@ onMounted(async () => {
 										v-else-if="
 											hasPermission(
 												'stations.djs.remove'
-											) &&
-											station.type === 'community' &&
-											isDj(user._id)
+											) && isDj(user._id)
 										"
 										class="button is-danger material-icons"
 										@click.prevent="removeDj(user._id)"
@@ -421,7 +413,6 @@ onMounted(async () => {
 								<button
 									v-if="
 										hasPermission('stations.djs.add') &&
-										station.type === 'community' &&
 										!isDj(user._id) &&
 										!isOwner(user._id)
 									"
@@ -435,7 +426,6 @@ onMounted(async () => {
 								<button
 									v-else-if="
 										hasPermission('stations.djs.remove') &&
-										station.type === 'community' &&
 										isDj(user._id)
 									"
 									class="button is-danger material-icons"
@@ -571,34 +561,34 @@ onMounted(async () => {
 							color: var(--black);
 						}
 
+						.profile-picture {
+							margin-right: 10px;
+							width: 36px;
+							height: 36px;
+						}
+
+						:deep(.profile-picture.using-initials span) {
+							font-size: calc(
+								36px / 5 * 2
+							); // 2/5th of .profile-picture height/width
+						}
+
+						.user-rank {
+							color: var(--primary-color);
+							font-size: 18px;
+							margin: 0 5px;
+						}
+
+						.button {
+							margin-left: auto;
+							font-size: 18px;
+							width: 36px;
+						}
+
 						.left {
 							display: flex;
 							align-items: center;
 							flex: 1;
-
-							.profile-picture {
-								margin-right: 10px;
-								width: 36px;
-								height: 36px;
-							}
-
-							:deep(.profile-picture.using-initials span) {
-								font-size: calc(
-									36px / 5 * 2
-								); // 2/5th of .profile-picture height/width
-							}
-
-							.user-rank {
-								color: var(--primary-color);
-								font-size: 18px;
-								margin: 0 5px;
-							}
-
-							.button {
-								margin-left: auto;
-								font-size: 18px;
-								width: 36px;
-							}
 						}
 
 						.user-state {

+ 1 - 1
frontend/src/pages/Station/Sidebar/index.vue

@@ -67,7 +67,7 @@ onMounted(() => {
 				@click="showTab('users')"
 			>
 				Users
-				<span class="tag">{{ Math.min(userCount, 1) }}</span>
+				<span class="tag">{{ Math.max(userCount, 1) }}</span>
 			</button>
 			<button
 				v-if="canRequest()"