Ver código fonte

refactor: eslint fixes

Kristian Vos 2 anos atrás
pai
commit
9703d2c8fd

+ 2 - 2
backend/logic/actions/news.js

@@ -253,13 +253,13 @@ export default {
 	 * Gets the latest news item
 	 *
 	 * @param {object} session - the session object automatically added by the websocket
+	 * @param {boolean} newUser - whether the user requesting the newest news is a new user
 	 * @param {Function} cb - gets called with the result
 	 */
 	async newest(session, newUser, cb) {
 		const newsModel = await DBModule.runJob("GET_MODEL", { modelName: "news" }, this);
 		const query = { status: "published" };
-		if (newUser)
-			query.showToNewUsers = true;
+		if (newUser) query.showToNewUsers = true;
 		async.waterfall(
 			[next => newsModel.findOne(query).sort({ createdAt: "desc" }).exec(next)],
 			async (err, news) => {

+ 1 - 1
backend/logic/migration/migrations/migration19.js

@@ -19,7 +19,7 @@ export default async function migrate(MigrationModule) {
 					newsModel.updateMany(
 						{ documentVersion: 2 },
 						{
-							$set: { documentVersion: 3, showToNewUsers: false },
+							$set: { documentVersion: 3, showToNewUsers: false }
 						},
 						(err, res) => {
 							if (err) next(err);

+ 7 - 2
frontend/src/components/modals/EditNews.vue

@@ -126,8 +126,13 @@ export default {
 			if (this.newsId) {
 				this.socket.dispatch(`news.getNewsFromId`, this.newsId, res => {
 					if (res.status === "success") {
-						const { markdown, status, showToNewUsers, createdBy, createdAt } =
-							res.data.news;
+						const {
+							markdown,
+							status,
+							showToNewUsers,
+							createdBy,
+							createdAt
+						} = res.data.news;
 						this.markdown = markdown;
 						this.status = status;
 						this.showToNewUsers = showToNewUsers;

+ 15 - 17
frontend/src/components/modals/WhatIsNew.vue

@@ -66,7 +66,7 @@ export default {
 	},
 	methods: {
 		init() {
-			const newUser = !localStorage.hasOwnProperty("firstVisited");
+			const newUser = !localStorage.getItem("firstVisited");
 			this.socket.dispatch("news.newest", newUser, res => {
 				if (res.status !== "success") return;
 
@@ -76,28 +76,26 @@ export default {
 				if (this.news) {
 					if (newUser) {
 						this.openModal("whatIsNew");
-					} else if (localStorage.getItem("firstVisited")) {
-						if (localStorage.getItem("whatIsNew")) {
-							if (
-								parseInt(localStorage.getItem("whatIsNew")) <
-								news.createdAt
-							) {
-								this.openModal("whatIsNew");
-								localStorage.setItem("whatIsNew", news.createdAt);
-							}
-						} else {
-							if (
-								parseInt(localStorage.getItem("firstVisited")) <
-								news.createdAt
-							)
-								this.openModal("whatIsNew");
+					} else if (localStorage.getItem("whatIsNew")) {
+						if (
+							parseInt(localStorage.getItem("whatIsNew")) <
+							news.createdAt
+						) {
+							this.openModal("whatIsNew");
 							localStorage.setItem("whatIsNew", news.createdAt);
 						}
+					} else {
+						if (
+							parseInt(localStorage.getItem("firstVisited")) <
+							news.createdAt
+						)
+							this.openModal("whatIsNew");
+						localStorage.setItem("whatIsNew", news.createdAt);
 					}
 				}
 
 				if (!localStorage.getItem("firstVisited"))
-						localStorage.setItem("firstVisited", Date.now());
+					localStorage.setItem("firstVisited", Date.now());
 			});
 		},
 		marked,