From b24f368d3f207554735e4edc5c5a2b7e16a6d281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Mon, 10 Sep 2018 18:02:46 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B5=E3=83=AD=E3=82=B2=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=83=9A=E3=82=A2=E3=82=92=E5=AD=97=E6=95=B0=E3=81=AB=E3=82=AB?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=88=E3=81=97=E3=81=AA=E3=81=84=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B=20(#2661)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update post-form.vue * Update messaging-message.ts * Update post-form.vue * Update note.ts * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#issuecomment-419579444 * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#issuecomment-419579444 * Update messaging-message.ts refs: https://github.com/syuilo/misskey/pull/2661#issuecomment-419579444 * Update note.ts refs: https://github.com/syuilo/misskey/pull/2661#issuecomment-419579444 * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#discussion_r216175581 * Update post-form.vue * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#discussion_r216242002 * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#discussion_r216242105 --- src/client/app/desktop/views/components/post-form.vue | 9 +++++++-- src/client/app/mobile/views/components/post-form.vue | 7 ++++++- src/models/messaging-message.ts | 3 ++- src/models/note.ts | 5 +++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index fd489283f..483a51b0a 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 - text.length }}

+

{{ 1000 - this.trimmedLength(text) }}

@@ -63,6 +63,7 @@ import MkVisibilityChooser from '../../../common/views/components/visibility-cho import parse from '../../../../../mfm/parse'; import { host } from '../../../config'; import { erase } from '../../../../../prelude/array'; +import { length } from 'stringz'; import parseAcct from '../../../../../misc/acct/parse'; export default Vue.extend({ @@ -147,7 +148,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); + (length(this.text.trim()) <= 1000); } }, @@ -199,6 +200,10 @@ export default Vue.extend({ }, methods: { + trimmedLength(text: string) { + return length(text.trim()); + }, + addTag(tag: string) { insertTextAtCursor(this.$refs.text, ` #${tag} `); }, diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index 7e6a4c38e..be20b11f1 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 @@
- {{ 1000 - text.length }} + {{ 1000 - trimmedLength(text) }} %fa:map-marker-alt%
@@ -60,6 +60,7 @@ import getFace from '../../../common/scripts/get-face'; import parse from '../../../../../mfm/parse'; import { host } from '../../../config'; import { erase } from '../../../../../prelude/array'; +import { length } from 'stringz'; import parseAcct from '../../../../../misc/acct/parse'; export default Vue.extend({ @@ -180,6 +181,10 @@ export default Vue.extend({ }, methods: { + trimmedLength(text: string) { + return length(text.trim()); + }, + addTag(tag: string) { insertTextAtCursor(this.$refs.text, ` #${tag} `); }, diff --git a/src/models/messaging-message.ts b/src/models/messaging-message.ts index f46abd506..d778164de 100644 --- a/src/models/messaging-message.ts +++ b/src/models/messaging-message.ts @@ -4,6 +4,7 @@ import { pack as packUser } from './user'; import { pack as packFile } from './drive-file'; import db from '../db/mongodb'; import MessagingHistory, { deleteMessagingHistory } from './messaging-history'; +import { length } from 'stringz'; const MessagingMessage = db.get('messagingMessages'); export default MessagingMessage; @@ -19,7 +20,7 @@ export interface IMessagingMessage { } export function isValidText(text: string): boolean { - return text.length <= 1000 && text.trim() != ''; + return length(text.trim()) <= 1000 && text.trim() != ''; } /** diff --git a/src/models/note.ts b/src/models/note.ts index 624bdbdfe..6530d0b32 100644 --- a/src/models/note.ts +++ b/src/models/note.ts @@ -2,6 +2,7 @@ import * as mongo from 'mongodb'; const deepcopy = require('deepcopy'); import rap from '@prezzemolo/rap'; import db from '../db/mongodb'; +import { length } from 'stringz'; import { IUser, pack as packUser } from './user'; import { pack as packApp } from './app'; import PollVote, { deletePollVote } from './poll-vote'; @@ -24,11 +25,11 @@ Note.createIndex({ export default Note; export function isValidText(text: string): boolean { - return text.length <= 1000 && text.trim() != ''; + return length(text.trim()) <= 1000 && text.trim() != ''; } export function isValidCw(text: string): boolean { - return text.length <= 100; + return length(text.trim()) <= 100; } export type INote = {