diff --git a/locales/index.d.ts b/locales/index.d.ts index 977fb43be4..2c9e3e3890 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -12947,6 +12947,16 @@ export interface Locale extends ILocale { * If disabled, then the proxy account will not be used. User lists will only include notes from local or followed users. */ "enableProxyAccountDescription": string; + "_confirmPollEdit": { + /** + * Are you sure you want to edit this poll? + */ + "title": string; + /** + * Editing this poll will cause it to lose all previous votes + */ + "text": string; + }; } declare const locales: { [lang: string]: Locale; diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 5f4e40d513..ef3dafb593 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -186,6 +186,7 @@ const posted = ref(false); const text = ref(props.initialText ?? ''); const files = ref(props.initialFiles ?? []); const poll = ref(null); +const initialPoll = ref(null); const useCw = ref(!!props.initialCw); const showPreview = ref(store.s.showPreview); watch(showPreview, () => store.set('showPreview', showPreview.value)); @@ -978,6 +979,15 @@ async function post(ev?: MouseEvent) { token = storedAccounts.find(x => x.id === postAccount.value?.id)?.token; } + if (postData.editId && postData.poll !== initialPoll.value) { + const { canceled } = await os.confirm({ + type: 'warning', + title: i18n.ts._confirmPollEdit.title, + text: i18n.ts._confirmPollEdit.text, + }); + if (canceled) return; + } + posting.value = true; misskeyApi(postData.editId ? 'notes/edit' : (postData.scheduleNote ? 'notes/schedule/create' : 'notes/create'), postData, token).then(() => { if (props.freezeAfterPosted) { @@ -1201,6 +1211,7 @@ onMounted(() => { expiresAt: init.poll.expiresAt ? (new Date(init.poll.expiresAt)).getTime() : null, expiredAfter: null, }; + if (props.editId) initialPoll.value = poll.value; } if (init.visibleUserIds) { misskeyApi('users/show', { userIds: init.visibleUserIds }).then(users => { diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index 635684596b..8f217a1d3a 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -536,3 +536,7 @@ deleted: "Deleted" enableProxyAccount: "Enable the proxy account." enableProxyAccountDescription: "If disabled, then the proxy account will not be used. User lists will only include notes from local or followed users." + +_confirmPollEdit: + title: Are you sure you want to edit this poll? + text: Editing this poll will cause it to lose all previous votes