From 2c76d410ab4ece8163f3492c146454b0b8822e94 Mon Sep 17 00:00:00 2001
From: syuilo <Syuilotan@yahoo.co.jp>
Date: Thu, 4 Jul 2019 22:59:52 +0900
Subject: [PATCH] Resolve #1867

---
 CHANGELOG.md                                   |  1 +
 .../app/common/views/components/dialog.vue     | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 17b622381b..ac5d697be5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ unreleased
 * AP: attributedTo, to, cc が Array や Object のパターンに対応
 * AP: object type が Audio, Document, Image, Page, Video のパターンに対応
 * フォロー解除時に確認ダイアログを表示するように
+* ユーザー入力ダイアログで、入力時にユーザーの存在を確認するように
 
 ### 🐛Fixes
 * 自分のインスタンスのルートURIへのリンクが無になる問題を修正
diff --git a/src/client/app/common/views/components/dialog.vue b/src/client/app/common/views/components/dialog.vue
index a577da5a21..ed94fe5f35 100644
--- a/src/client/app/common/views/components/dialog.vue
+++ b/src/client/app/common/views/components/dialog.vue
@@ -33,7 +33,7 @@
 				</template>
 			</ui-select>
 			<ui-horizon-group no-grow class="buttons fit-bottom" v-if="!splash && (showOkButton || showCancelButton)">
-				<ui-button @click="ok" v-if="showOkButton" primary :autofocus="!input && !select && !user">{{ (showCancelButton || input || select || user) ? $t('@.ok') : $t('@.got-it') }}</ui-button>
+				<ui-button @click="ok" v-if="showOkButton" primary :autofocus="!input && !select && !user" :disabled="!canOk">{{ (showCancelButton || input || select || user) ? $t('@.ok') : $t('@.got-it') }}</ui-button>
 				<ui-button @click="cancel" v-if="showCancelButton || input || select || user">{{ $t('@.cancel') }}</ui-button>
 			</ui-horizon-group>
 		</template>
@@ -99,11 +99,26 @@ export default Vue.extend({
 			inputValue: this.input && this.input.default ? this.input.default : null,
 			userInputValue: null,
 			selectedValue: this.select ? this.select.items ? this.select.items[0].value : this.select.groupedItems[0].items[0].value : null,
+			canOk: true,
 			faTimesCircle, faQuestionCircle
 		};
 	},
 
+	watch: {
+		userInputValue() {
+			if (this.user) {
+				this.$root.api('users/show', parseAcct(this.userInputValue)).then(u => {
+					this.canOk = u != null;
+				}).catch(() => {
+					this.canOk = false;
+				});
+			}
+		}
+	},
+
 	mounted() {
+		if (this.user) this.canOk = false;
+
 		this.$nextTick(() => {
 			(this.$refs.bg as any).style.pointerEvents = 'auto';
 			anime({
@@ -131,6 +146,7 @@ export default Vue.extend({
 
 	methods: {
 		async ok() {
+			if (!this.canOk) return;
 			if (!this.showOkButton) return;
 
 			if (this.user) {
-- 
GitLab