2020-10-17 14:12:00 +03:00
|
|
|
<template>
|
|
|
|
<div class="_section">
|
|
|
|
<div class="_card">
|
|
|
|
<div class="_title"><Fa :icon="faLaugh"/> {{ $t('reaction') }}</div>
|
|
|
|
<div class="_content">
|
2020-11-15 03:35:36 +02:00
|
|
|
<div class="_caption" style="padding: 0 8px 8px 8px;">{{ $t('reactionSettingDescription') }}</div>
|
2020-11-14 07:32:01 +02:00
|
|
|
<XDraggable class="zoaiodol" :list="reactions" animation="150" delay="100" delay-on-touch-only="true">
|
|
|
|
<button class="_button item" v-for="reaction in reactions" :key="reaction" @click="remove(reaction, $event)">
|
|
|
|
<MkEmoji :emoji="reaction" :normal="true"/>
|
|
|
|
</button>
|
|
|
|
<template #footer>
|
|
|
|
<button>a</button>
|
|
|
|
</template>
|
|
|
|
</XDraggable>
|
2020-11-15 03:35:36 +02:00
|
|
|
<div class="_caption" style="padding: 8px;">{{ $t('reactionSettingDescription2') }} <button class="_textButton" @click="chooseEmoji">{{ $t('chooseEmoji') }}</button></div>
|
2020-11-18 05:09:14 +02:00
|
|
|
<MkRadios v-model="reactionPickerWidth">
|
|
|
|
<template #desc>{{ $t('width') }}</template>
|
|
|
|
<option :value="1">{{ $t('small') }}</option>
|
|
|
|
<option :value="2">{{ $t('medium') }}</option>
|
|
|
|
<option :value="3">{{ $t('large') }}</option>
|
|
|
|
</MkRadios>
|
|
|
|
<MkRadios v-model="reactionPickerHeight">
|
|
|
|
<template #desc>{{ $t('height') }}</template>
|
|
|
|
<option :value="1">{{ $t('small') }}</option>
|
|
|
|
<option :value="2">{{ $t('medium') }}</option>
|
|
|
|
<option :value="3">{{ $t('large') }}</option>
|
|
|
|
</MkRadios>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
|
|
|
<div class="_footer">
|
|
|
|
<MkButton inline @click="preview"><Fa :icon="faEye"/> {{ $t('preview') }}</MkButton>
|
2020-11-14 07:32:01 +02:00
|
|
|
<MkButton inline @click="setDefault"><Fa :icon="faUndo"/> {{ $t('default') }}</MkButton>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { faLaugh, faSave, faEye } from '@fortawesome/free-regular-svg-icons';
|
|
|
|
import { faUndo } from '@fortawesome/free-solid-svg-icons';
|
2020-11-14 07:32:01 +02:00
|
|
|
import { VueDraggableNext } from 'vue-draggable-next';
|
2020-10-17 14:12:00 +03:00
|
|
|
import MkInput from '@/components/ui/input.vue';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
2020-11-07 03:43:27 +02:00
|
|
|
import MkSwitch from '@/components/ui/switch.vue';
|
2020-11-18 05:09:14 +02:00
|
|
|
import MkRadios from '@/components/ui/radios.vue';
|
2020-10-17 14:12:00 +03:00
|
|
|
import { emojiRegexWithCustom } from '../../../misc/emoji-regex';
|
|
|
|
import { defaultSettings } from '@/store';
|
|
|
|
import * as os from '@/os';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkInput,
|
|
|
|
MkButton,
|
2020-11-07 03:43:27 +02:00
|
|
|
MkSwitch,
|
2020-11-18 05:09:14 +02:00
|
|
|
MkRadios,
|
2020-11-14 07:32:01 +02:00
|
|
|
XDraggable: VueDraggableNext,
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
INFO: {
|
2020-11-03 13:36:12 +02:00
|
|
|
title: this.$t('reaction'),
|
|
|
|
icon: faLaugh
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
2020-11-14 07:32:01 +02:00
|
|
|
reactions: JSON.parse(JSON.stringify(this.$store.state.settings.reactions)),
|
2020-10-17 14:12:00 +03:00
|
|
|
faLaugh, faSave, faEye, faUndo
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-11-07 03:43:27 +02:00
|
|
|
useFullReactionPicker: {
|
|
|
|
get() { return this.$store.state.device.useFullReactionPicker; },
|
|
|
|
set(value) { this.$store.commit('device/set', { key: 'useFullReactionPicker', value: value }); }
|
|
|
|
},
|
2020-11-18 05:09:14 +02:00
|
|
|
reactionPickerWidth: {
|
|
|
|
get() { return this.$store.state.device.reactionPickerWidth; },
|
|
|
|
set(value) { this.$store.commit('device/set', { key: 'reactionPickerWidth', value: value }); }
|
|
|
|
},
|
|
|
|
reactionPickerHeight: {
|
|
|
|
get() { return this.$store.state.device.reactionPickerHeight; },
|
|
|
|
set(value) { this.$store.commit('device/set', { key: 'reactionPickerHeight', value: value }); }
|
|
|
|
},
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
reactions: {
|
|
|
|
handler() {
|
2020-11-14 07:32:01 +02:00
|
|
|
this.save();
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
deep: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
save() {
|
2020-11-14 07:32:01 +02:00
|
|
|
this.$store.dispatch('settings/set', { key: 'reactions', value: this.reactions });
|
|
|
|
},
|
|
|
|
|
|
|
|
remove(reaction, ev) {
|
|
|
|
os.modalMenu([{
|
|
|
|
text: this.$t('remove'),
|
|
|
|
action: () => {
|
|
|
|
this.reactions = this.reactions.filter(x => x !== reaction)
|
|
|
|
}
|
|
|
|
}], ev.currentTarget || ev.target);
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
|
2020-11-03 08:22:55 +02:00
|
|
|
preview(ev) {
|
2020-11-14 04:47:30 +02:00
|
|
|
os.popup(import('@/components/emoji-picker.vue'), {
|
2020-11-18 05:09:14 +02:00
|
|
|
asReactionPicker: true,
|
2020-11-14 04:47:30 +02:00
|
|
|
src: ev.currentTarget || ev.target,
|
|
|
|
}, {}, 'closed');
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
|
2020-11-14 07:32:01 +02:00
|
|
|
async setDefault() {
|
|
|
|
const { canceled } = await os.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('resetAreYouSure'),
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
this.reactions = JSON.parse(JSON.stringify(defaultSettings.reactions));
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
|
2020-11-03 08:22:55 +02:00
|
|
|
chooseEmoji(ev) {
|
2020-11-14 07:32:01 +02:00
|
|
|
os.pickEmoji(ev.currentTarget || ev.target, {
|
|
|
|
showPinned: false
|
|
|
|
}).then(emoji => {
|
|
|
|
if (!this.reactions.includes(emoji)) {
|
|
|
|
this.reactions.push(emoji);
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-11-14 07:32:01 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.zoaiodol {
|
|
|
|
border: solid 1px var(--divider);
|
|
|
|
border-radius: var(--radius);
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> .item {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 8px;
|
|
|
|
cursor: move;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|