Parcourir la source

fix(Report modal): added socket listener for when a user's previous report is removed

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan il y a 3 ans
Parent
commit
e8e3470f84
1 fichiers modifiés avec 18 ajouts et 1 suppressions
  1. 18 1
      frontend/src/components/modals/Report.vue

+ 18 - 1
frontend/src/components/modals/Report.vue

@@ -353,9 +353,26 @@ export default {
 	},
 	mounted() {
 		this.socket.dispatch("reports.myReportsForSong", this.song._id, res => {
-			if (res.status === "success")
+			if (res.status === "success") {
 				this.existingReports = res.data.reports;
+				this.existingReports.forEach(report =>
+					this.socket.dispatch(
+						"apis.joinRoom",
+						`view-report.${report._id}`
+					)
+				);
+			}
 		});
+
+		this.socket.on(
+			"event:admin.report.resolved",
+			res => {
+				this.existingReports = this.existingReports.filter(
+					report => report._id !== res.data.reportId
+				);
+			},
+			{ modal: "report" }
+		);
 	},
 	methods: {
 		view(reportId) {