mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Added mute end date (#10566)
* Added mute end date * Added indefinite mute for users using slurs * Fixed user reload. Added no longer muted message. Added format for date * Fixed lint
This commit is contained in:
@@ -55,10 +55,21 @@
|
||||
div(v-if="expandAuth")
|
||||
pre {{hero.auth}}
|
||||
.form-group
|
||||
h5 User Mute Settings
|
||||
.checkbox
|
||||
label
|
||||
input(type='checkbox', v-if='hero.flags', v-model='hero.flags.chatRevoked')
|
||||
| Chat Privileges Revoked
|
||||
strong Chat Privileges Revoked
|
||||
div(v-if='hero.flags.chatRevoked && hero.flags.chatRevokedEndDate')
|
||||
strong User is currently muted until
|
||||
br
|
||||
div {{ userRevokedEndDate(hero) }}
|
||||
div(v-else-if='hero.flags.chatRevoked')
|
||||
strong User is currently muted indefinitely
|
||||
div
|
||||
strong For how many days from today do you want to mute this user? Leave as 0 for indefinite.
|
||||
br
|
||||
input(type='number', v-model='numberOfDaysToMute')
|
||||
.form-group
|
||||
.checkbox
|
||||
label
|
||||
@@ -103,7 +114,7 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// import keys from 'lodash/keys';
|
||||
import moment from 'moment';
|
||||
import each from 'lodash/each';
|
||||
|
||||
import markdownDirective from 'client/directives/markdown';
|
||||
@@ -132,6 +143,7 @@ export default {
|
||||
gear,
|
||||
expandItems: false,
|
||||
expandAuth: false,
|
||||
numberOfDaysToMute: 0,
|
||||
};
|
||||
},
|
||||
directives: {
|
||||
@@ -144,6 +156,10 @@ export default {
|
||||
...mapState({user: 'user.data'}),
|
||||
},
|
||||
methods: {
|
||||
userRevokedEndDate (hero) {
|
||||
if (moment().isAfter(moment(hero.flags.chatRevokedEndDate))) return 'User is no longer muted';
|
||||
return moment(hero.flags.chatRevokedEndDate).format(this.user.preferences.dateFormat.toUpperCase());
|
||||
},
|
||||
getAllItemPaths () {
|
||||
// let questsFormat = this.getFormattedItemReference('items.quests', keys(this.quests), 'Numeric Quantity');
|
||||
// let mountsFormat = this.getFormattedItemReference('items.mounts', keys(this.mountInfo), 'Boolean');
|
||||
@@ -174,7 +190,7 @@ export default {
|
||||
async loadHero (uuid, heroIndex) {
|
||||
this.currentHeroIndex = heroIndex;
|
||||
let hero = await this.$store.dispatch('hall:getHero', { uuid });
|
||||
this.hero = Object.assign({}, this.hero, hero);
|
||||
this.hero = Object.assign({}, hero);
|
||||
if (!this.hero.flags) {
|
||||
this.hero.flags = {
|
||||
chatRevoked: false,
|
||||
@@ -184,6 +200,11 @@ export default {
|
||||
this.expandAuth = false;
|
||||
},
|
||||
async saveHero () {
|
||||
if (this.numberOfDaysToMute) {
|
||||
const dayToEndMute = moment().add(this.numberOfDaysToMute, 'days').utc().toDate();
|
||||
this.hero.flags.chatRevokedEndDate = dayToEndMute;
|
||||
}
|
||||
|
||||
this.hero.contributor.admin = this.hero.contributor.level > 7 ? true : false;
|
||||
let heroUpdated = await this.$store.dispatch('hall:updateHero', { heroDetails: this.hero });
|
||||
this.text('User updated');
|
||||
@@ -191,6 +212,7 @@ export default {
|
||||
this.heroID = -1;
|
||||
this.heroes[this.currentHeroIndex] = heroUpdated;
|
||||
this.currentHeroIndex = -1;
|
||||
this.numberOfDaysToMute = 0;
|
||||
},
|
||||
populateContributorInput (id, index) {
|
||||
this.heroID = id;
|
||||
|
||||
Reference in New Issue
Block a user