Skip to content

Commit

Permalink
Include the creator in the moderator list
Browse files Browse the repository at this point in the history
Related to Issue #44
  • Loading branch information
BobChao87 committed Oct 29, 2021
1 parent 81ab835 commit 889eefe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions components/marathon/sidebar/Moderators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script lang="ts">
import Vue from 'vue';
import { mapActions } from 'vuex';
import { MarathonState } from '~/types/api/marathon';
import { FullMarathon, MarathonState } from '~/types/api/marathon';
import { User } from '~/types/api/user';
export default Vue.extend({
Expand All @@ -38,8 +38,17 @@ export default Vue.extend({
},
computed: {
moderators(): Array<User>|undefined {
return (this.$store.state.api.marathon as MarathonState).marathons[this.marathonId]?.moderators;
marathon(): FullMarathon|undefined {
return (this.$store.state.api.marathon as MarathonState).marathons[this.marathonId];
},
moderators(): Array<User> {
const moderators = [ ...(this.marathon?.moderators ?? [ ]) ];
const creator = this.marathon?.creator;
// XXX Fix to prevent duplication. See https://github.com/esamarathon/oengusio/issues/129
if (creator && moderators.every(moderator => moderator.id !== creator.id)) {
moderators.unshift(creator);
}
return moderators;
},
},
Expand Down

0 comments on commit 889eefe

Please sign in to comment.