From 11cb134d4d28f3e9e816affcbb1ba98d68e7d9e2 Mon Sep 17 00:00:00 2001
From: KevinWh0 <45321184+KevinWh0@users.noreply.github.com>
Date: Fri, 16 Feb 2024 21:53:27 +0100
Subject: It works, Just figuring out some ts errors hopefully

---
 packages/frontend/src/components/MkPostForm.vue | 35 ++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

(limited to 'packages/frontend/src/components/MkPostForm.vue')

diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue
index 65ffb7b7a5..25e51fd52c 100644
--- a/packages/frontend/src/components/MkPostForm.vue
+++ b/packages/frontend/src/components/MkPostForm.vue
@@ -101,7 +101,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 </template>
 
 <script lang="ts" setup>
-import { inject, watch, nextTick, onMounted, defineAsyncComponent, provide, shallowRef, ref, computed } from 'vue';
+import { inject, watch, nextTick, onMounted, defineAsyncComponent, provide, shallowRef, ref, computed, toRaw } from 'vue';
 import * as mfm from '@transfem-org/sfm-js';
 import * as Misskey from 'misskey-js';
 import insertTextAtCursor from 'insert-text-at-cursor';
@@ -744,6 +744,39 @@ async function post(ev?: MouseEvent) {
 			visibility.value = 'home';
 		}
 	}
+	
+	if (defaultStore.state.warnMissingAltText) {
+		const filesData = toRaw(files.value);
+		for (let i = 0; i < filesData.length; i++) {
+			const file = filesData[i];
+			const isMissingAltText = !file.comment;
+			if (isMissingAltText) {
+				const { canceled, result } = await os.actions({
+					type: 'warning',
+					text: i18n.ts.thisPostIsMissingAltText,
+					actions: [{
+						value: 'cancel',
+						text: i18n.ts.thisPostIsMissingAltTextCancel,
+					}, {
+						value: 'ignore',
+						text: i18n.ts.thisPostIsMissingAltTextIgnore,
+					}],
+				});
+
+				if (canceled) return;
+				if (result === 'cancel') return;
+				if (result === 'home') {
+					visibility.value = 'home';
+				}
+
+				// await os.alert({
+				// 	type: 'info',
+				// 	text: i18n.ts.thisPostIsMissingAltText,
+				// });
+				// return;
+			}
+		}
+	}
 
 	let postData = {
 		text: text.value === '' ? null : text.value,
-- 
cgit v1.2.3-freya

