From daa22d68fa8a55a2e65a1de541f903edb64ff042 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Wed, 24 Oct 2018 04:00:04 +0900 Subject: [PATCH] Make max allowed text length configurable (#2992) * Make max allowed text length configurable * Fix canPost --- .config/example.yml | 3 +++ .../app/desktop/views/components/post-form.vue | 13 ++++++++++--- .../app/mobile/views/components/post-form.vue | 13 ++++++++++--- src/config/load.ts | 2 ++ src/config/types.ts | 2 ++ src/models/note.ts | 3 ++- src/server/api/endpoints/meta.ts | 1 + 7 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index ea83f9cfb8..48fc360f3f 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -164,3 +164,6 @@ drive: # external: true # engine: http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}} # timeout: 300000 + +# Max allowed note text length in charactors +maxNoteTextLength: 1000 diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index 3835f7228e..a703382f38 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -45,7 +45,7 @@ %fa:envelope% %fa:lock% -
{{ 1000 - this.trimmedLength(text) }}
+{{ this.maxNoteTextLength - this.trimmedLength(text) }}
@@ -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); } }, diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index e532430d0f..0c783fded3 100644 --- a/src/client/app/mobile/views/components/post-form.vue +++ b/src/client/app/mobile/views/components/post-form.vue @@ -4,7 +4,7 @@