Make max allowed text length configurable (#2992)

* Make max allowed text length configurable

* Fix canPost
This commit is contained in:
MeiMei
2018-10-24 04:00:04 +09:00
committed by syuilo
parent f24d202024
commit daa22d68fa
7 changed files with 30 additions and 7 deletions

View File

@ -45,7 +45,7 @@
<span v-if="visibility === 'specified'">%fa:envelope%</span>
<span v-if="visibility === 'private'">%fa:lock%</span>
</button>
<p class="text-count" :class="{ over: this.trimmedLength(text) > 1000 }">{{ 1000 - this.trimmedLength(text) }}</p>
<p class="text-count" :class="{ over: this.trimmedLength(text) > this.maxNoteTextLength }">{{ this.maxNoteTextLength - this.trimmedLength(text) }}</p>
<button :class="{ posting }" class="submit" :disabled="!canPost" @click="post">
{{ posting ? '%i18n:@posting%' : submitText }}<mk-ellipsis v-if="posting"/>
</button>
@ -107,10 +107,17 @@ export default Vue.extend({
visibleUsers: [],
autocomplete: null,
draghover: false,
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]')
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]'),
maxNoteTextLength: 1000
};
},
created() {
(this as any).os.getMeta().then(meta => {
this.maxNoteTextLength = meta.maxNoteTextLength;
});
},
computed: {
draftId(): string {
return this.renote
@ -149,7 +156,7 @@ 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()) <= 1000);
(length(this.text.trim()) <= this.maxNoteTextLength);
}
},

View File

@ -4,7 +4,7 @@
<header>
<button class="cancel" @click="cancel">%fa:times%</button>
<div>
<span class="text-count" :class="{ over: trimmedLength(text) > 1000 }">{{ 1000 - trimmedLength(text) }}</span>
<span class="text-count" :class="{ over: trimmedLength(text) > this.maxNoteTextLength }">{{ this.maxNoteTextLength - trimmedLength(text) }}</span>
<span class="geo" v-if="geo">%fa:map-marker-alt%</span>
<button class="submit" :disabled="!canPost" @click="post">{{ submitText }}</button>
</div>
@ -102,10 +102,17 @@ export default Vue.extend({
visibleUsers: [],
useCw: false,
cw: null,
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]')
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]'),
maxNoteTextLength: 1000
};
},
created() {
(this as any).os.getMeta().then(meta => {
this.maxNoteTextLength = meta.maxNoteTextLength;
});
},
computed: {
draftId(): string {
return this.renote
@ -144,7 +151,7 @@ export default Vue.extend({
canPost(): boolean {
return !this.posting &&
(1 <= this.text.length || 1 <= this.files.length || this.poll || this.renote) &&
(this.text.trim().length <= 1000);
(this.text.trim().length <= this.maxNoteTextLength);
}
},