なんかもうめっちゃ変えた

Resolve #5846
This commit is contained in:
syuilo
2020-02-10 23:17:42 +09:00
parent 9cd267fee5
commit 2511114c28
20 changed files with 173 additions and 221 deletions

View File

@ -143,7 +143,7 @@ export default Vue.extend({
this.setPosition();
//#region Construct Emoji DB
const customEmojis = (this.$root.getMetaSync() || { emojis: [] }).emojis || [];
const customEmojis = this.$store.state.instance.meta.emojis;
const emojiDefinitions: EmojiDef[] = [];
for (const x of customEmojis) {

View File

@ -140,7 +140,7 @@ export default Vue.extend({
},
created() {
let local = (this.$root.getMetaSync() || { emojis: [] }).emojis || [];
let local = this.$store.state.instance.meta.emojis;
local = groupByX(local, (x: any) => x.category || '');
this.customEmojis = local;
},

View File

@ -55,38 +55,35 @@ export default Vue.extend({
useOsDefaultEmojis(): boolean {
return this.$store.state.device.useOsDefaultEmojis && !this.isReaction;
},
ce() {
let ce = [];
if (this.customEmojis) ce = ce.concat(this.customEmojis);
if (this.$store.state.instance.meta && this.$store.state.instance.meta.emojis) ce = ce.concat(this.$store.state.instance.meta.emojis);
return ce;
}
},
watch: {
customEmojis() {
if (this.name) {
const customEmoji = this.customEmojis.find(x => x.name == this.name);
if (customEmoji) {
this.customEmoji = customEmoji;
this.url = this.$store.state.device.disableShowingAnimatedImages
? getStaticImageUrl(customEmoji.url)
: customEmoji.url;
ce: {
handler() {
if (this.name) {
const customEmoji = this.ce.find(x => x.name == this.name);
if (customEmoji) {
this.customEmoji = customEmoji;
this.url = this.$store.state.device.disableShowingAnimatedImages
? getStaticImageUrl(customEmoji.url)
: customEmoji.url;
}
}
}
},
immediate: true
},
},
created() {
if (this.name) {
const customEmoji = this.customEmojis.find(x => x.name == this.name);
if (customEmoji) {
this.customEmoji = customEmoji;
this.url = this.$store.state.device.disableShowingAnimatedImages
? getStaticImageUrl(customEmoji.url)
: customEmoji.url;
} else {
//const emoji = lib[this.name];
//if (emoji) {
// this.char = emoji.char;
//}
}
} else {
if (!this.name) {
this.char = this.emoji;
}

View File

@ -234,7 +234,6 @@ export default Vue.component('misskey-flavored-markdown', {
}
case 'emoji': {
const customEmojis = (this.$root.getMetaSync() || { emojis: [] }).emojis || [];
return [createElement('mk-emoji', {
key: Math.random(),
attrs: {
@ -242,7 +241,7 @@ export default Vue.component('misskey-flavored-markdown', {
name: token.node.props.name
},
props: {
customEmojis: this.customEmojis || customEmojis,
customEmojis: this.customEmojis,
normal: this.plain
}
})];

View File

@ -8,7 +8,7 @@
<header>
<button class="cancel _button" @click="cancel"><fa :icon="faTimes"/></button>
<div>
<span class="text-count" :class="{ over: trimmedLength(text) > 500 }">{{ 500 - trimmedLength(text) }}</span>
<span class="text-count" :class="{ over: trimmedLength(text) > max }">{{ max - trimmedLength(text) }}</span>
<button class="_button visibility" @click="setVisibility" ref="visibilityButton">
<span v-if="visibility === 'public'"><fa :icon="faGlobe"/></span>
<span v-if="visibility === 'home'"><fa :icon="faHome"/></span>
@ -172,8 +172,12 @@ export default Vue.extend({
canPost(): boolean {
return !this.posting &&
(1 <= this.text.length || 1 <= this.files.length || this.poll || this.renote) &&
(length(this.text.trim()) <= 500) &&
(length(this.text.trim()) <= this.max) &&
(!this.poll || this.pollChoices.length >= 2);
},
max(): number {
return this.$store.state.instance.meta ? this.$store.state.instance.meta.maxNoteTextLength : 1000;
}
},

View File

@ -1,5 +1,5 @@
<template>
<mk-emoji :emoji="reaction.startsWith(':') ? null : reaction" :name="reaction.startsWith(':') ? reaction.substr(1, reaction.length - 2) : null" :is-reaction="true" :custom-emojis="customEmojis" :normal="true" :no-style="noStyle"/>
<mk-emoji :emoji="reaction.startsWith(':') ? null : reaction" :name="reaction.startsWith(':') ? reaction.substr(1, reaction.length - 2) : null" :is-reaction="true" :normal="true" :no-style="noStyle"/>
</template>
<script lang="ts">
@ -18,15 +18,5 @@ export default Vue.extend({
default: false
},
},
data() {
return {
customEmojis: []
};
},
created() {
this.$root.getMeta().then(meta => {
if (meta && meta.emojis) this.customEmojis = meta.emojis;
});
},
});
</script>

View File

@ -82,7 +82,6 @@ export default Vue.extend({
token: '',
apiUrl,
host: toUnicode(host),
meta: null,
totpLogin: false,
credential: null,
challengeData: null,
@ -91,11 +90,13 @@ export default Vue.extend({
};
},
created() {
this.$root.getMeta().then(meta => {
this.meta = meta;
});
computed: {
meta() {
return this.$store.state.instance.meta;
},
},
created() {
if (this.autoSet) {
this.$once('login', res => {
localStorage.setItem('i', res.i);

View File

@ -79,7 +79,6 @@ export default Vue.extend({
usernameState: null,
passwordStrength: '',
passwordRetypeState: null,
meta: {},
submitting: false,
ToSAgreement: false,
faLock, faExclamationTriangle, faSpinner, faCheck
@ -87,6 +86,10 @@ export default Vue.extend({
},
computed: {
meta() {
return this.$store.state.instance.meta;
},
shouldShowProfileUrl(): boolean {
return (this.username != '' &&
this.usernameState != 'invalid-format' &&
@ -95,12 +98,6 @@ export default Vue.extend({
}
},
created() {
this.$root.getMeta().then(meta => {
this.meta = meta;
});
},
mounted() {
const head = document.getElementsByTagName('head')[0];
const script = document.createElement('script');