Set default event visibility from group privacy setting

Closes #912
This commit is contained in:
allilengyi 2022-02-21 20:26:43 +01:00 committed by Thomas Citharel
parent 9b7cd5831a
commit a407a56051
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -616,6 +616,7 @@ import {
EventJoinOptions,
EventStatus,
EventVisibility,
GroupVisibility,
MemberRole,
ParticipantRole,
} from "@/types/enums";
@ -639,6 +640,7 @@ import {
LOGGED_USER_DRAFTS,
PERSON_STATUS_GROUP,
} from "../../graphql/actor";
import { FETCH_GROUP } from "../../graphql/group";
import {
displayNameAndUsername,
IActor,
@ -719,6 +721,21 @@ const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
);
},
},
group: {
query: FETCH_GROUP,
fetchPolicy: "cache-and-network",
variables() {
return {
name: this.event?.attributedTo?.preferredUsername,
};
},
skip() {
return (
!this.event?.attributedTo ||
!this.event?.attributedTo?.preferredUsername
);
},
},
},
metaInfo() {
return {
@ -737,6 +754,8 @@ export default class EditEvent extends Vue {
@Prop({ type: Boolean, default: false }) isDuplicate!: boolean;
group!: IGroup;
currentActor!: IActor;
loggedUser!: IUser;
@ -782,6 +801,16 @@ export default class EditEvent extends Vue {
}
}
@Watch("group")
updateEventVisibility(group: IGroup): void {
if (!this.isUpdate && group.visibility == GroupVisibility.UNLISTED) {
this.event.visibility = EventVisibility.UNLISTED;
}
if (!this.isUpdate && group.visibility == GroupVisibility.PUBLIC) {
this.event.visibility = EventVisibility.PUBLIC;
}
}
private initializeEvent() {
const roundUpTo15Minutes = (time: Date) => {
time.setMilliseconds(Math.round(time.getMilliseconds() / 1000) * 1000);