From 9b726fabb5c3da115eba49fb82560a33a97acd31 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 22 Sep 2020 15:04:29 +0200 Subject: [PATCH] Make sure anonymous participation doesn't show up when logged-in And improve a little typescript usage Signed-off-by: Thomas Citharel --- js/src/views/Event/Event.vue | 48 +++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/js/src/views/Event/Event.vue b/js/src/views/Event/Event.vue index 050289ca8..397f0809f 100644 --- a/js/src/views/Event/Event.vue +++ b/js/src/views/Event/Event.vue @@ -104,11 +104,11 @@ /> {{ $t("Cancel anonymous participation") }} - + {{ $t("You are participating in this event anonymously") }} + {{ $t( "You are participating in this event anonymously but didn't confirm participation" @@ -622,13 +622,13 @@ import PopoverActorCard from "../../components/Account/PopoverActorCard.vue"; metaInfo() { return { // if no subcomponents specify a metaInfo.title, this title will be used - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore title: this.eventTitle, // all titles will be injected into this template titleTemplate: "%s | Mobilizon", meta: [ - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore { name: "description", content: this.eventDescription }, ], @@ -680,17 +680,17 @@ export default class Event extends EventMixin { messageForConfirmation = ""; - get eventTitle() { + get eventTitle(): undefined | string { if (!this.event) return undefined; return this.event.title; } - get eventDescription() { + get eventDescription(): undefined | string { if (!this.event) return undefined; return this.event.description; } - async mounted() { + async mounted(): Promise { this.identity = this.currentActor; if (this.$route.hash.includes("#comment-")) { this.loadComments = true; @@ -766,12 +766,13 @@ export default class Event extends EventMixin { /** * Delete the event, then redirect to home. */ - async openDeleteEventModalWrapper() { + async openDeleteEventModalWrapper(): Promise { await this.openDeleteEventModal(this.event, this.currentActor); } - async reportEvent(content: string, forward: boolean) { + async reportEvent(content: string, forward: boolean): Promise { this.isReportModalActive = false; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore this.$refs.reportModal.close(); if (!this.event.organizerActor) return; @@ -800,12 +801,12 @@ export default class Event extends EventMixin { } } - joinEventWithConfirmation(actor: IPerson) { + joinEventWithConfirmation(actor: IPerson): void { this.isJoinConfirmationModalActive = true; this.actorForConfirmation = actor; } - async joinEvent(identity: IPerson, message: string | null = null) { + async joinEvent(identity: IPerson, message: string | null = null): Promise { this.isJoinConfirmationModalActive = false; this.isJoinModalActive = false; try { @@ -874,7 +875,7 @@ export default class Event extends EventMixin { } } - confirmLeave() { + confirmLeave(): void { this.$buefy.dialog.confirm({ title: this.$t('Leaving event "{title}"', { title: this.event.title, @@ -895,7 +896,7 @@ export default class Event extends EventMixin { } @Watch("participations") - watchParticipations() { + watchParticipations(): void { if (this.participations.length > 0) { if ( this.oldParticipationRole && @@ -934,7 +935,7 @@ export default class Event extends EventMixin { this.$notifier.info(this.$t("Your participation status has been changed") as string); } - async downloadIcsEvent() { + async downloadIcsEvent(): Promise { const data = await ( await fetch(`${GRAPHQL_API_ENDPOINT}/events/${this.uuid}/export/ics`) ).text(); @@ -947,10 +948,12 @@ export default class Event extends EventMixin { document.body.removeChild(link); } - triggerShare() { + triggerShare(): void { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore-start if (navigator.share) { navigator + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore .share({ title: this.event.title, @@ -962,10 +965,11 @@ export default class Event extends EventMixin { this.isShareModalActive = true; // send popup } + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore-end } - async handleErrors(errors: GraphQLError[]) { + async handleErrors(errors: GraphQLError[]): Promise { if ( errors[0].message.includes("not found") || errors[0].message.includes("has invalid value $uuid") @@ -974,7 +978,7 @@ export default class Event extends EventMixin { } } - get actorIsParticipant() { + get actorIsParticipant(): boolean { if (this.actorIsOrganizer) return true; return ( @@ -982,13 +986,13 @@ export default class Event extends EventMixin { ); } - get actorIsOrganizer() { + get actorIsOrganizer(): boolean { return ( this.participations.length > 0 && this.participations[0].role === ParticipantRole.CREATOR ); } - get endDate() { + get endDate(): Date { return this.event.endsOn !== null && this.event.endsOn > this.event.beginsOn ? this.event.endsOn : this.event.beginsOn; @@ -1014,7 +1018,7 @@ export default class Event extends EventMixin { return isParticipatingInThisEvent(this.uuid); } - async cancelAnonymousParticipation() { + async cancelAnonymousParticipation(): Promise { const token = (await getLeaveTokenForParticipation(this.uuid)) as string; await this.leaveEvent(this.event, this.config.anonymous.actorId, token); await removeAnonymousParticipation(this.uuid); @@ -1023,7 +1027,7 @@ export default class Event extends EventMixin { get ableToReport(): boolean { return ( - this.config && (this.currentActor.id != undefined || this.config.anonymous.reports.allowed) + this.config && (this.currentActor.id !== undefined || this.config.anonymous.reports.allowed) ); } }