add poll edit warning

This commit is contained in:
Marie 2025-05-08 19:47:18 +02:00
parent 17a9b08f54
commit b753b2ea3a
No known key found for this signature in database
GPG key ID: 7ADF6C9CD9A28555
3 changed files with 25 additions and 0 deletions

10
locales/index.d.ts vendored
View file

@ -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. * If disabled, then the proxy account will not be used. User lists will only include notes from local or followed users.
*/ */
"enableProxyAccountDescription": string; "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: { declare const locales: {
[lang: string]: Locale; [lang: string]: Locale;

View file

@ -186,6 +186,7 @@ const posted = ref(false);
const text = ref(props.initialText ?? ''); const text = ref(props.initialText ?? '');
const files = ref(props.initialFiles ?? []); const files = ref(props.initialFiles ?? []);
const poll = ref<PollEditorModelValue | null>(null); const poll = ref<PollEditorModelValue | null>(null);
const initialPoll = ref<PollEditorModelValue | null>(null);
const useCw = ref<boolean>(!!props.initialCw); const useCw = ref<boolean>(!!props.initialCw);
const showPreview = ref(store.s.showPreview); const showPreview = ref(store.s.showPreview);
watch(showPreview, () => store.set('showPreview', showPreview.value)); 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; 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; posting.value = true;
misskeyApi(postData.editId ? 'notes/edit' : (postData.scheduleNote ? 'notes/schedule/create' : 'notes/create'), postData, token).then(() => { misskeyApi(postData.editId ? 'notes/edit' : (postData.scheduleNote ? 'notes/schedule/create' : 'notes/create'), postData, token).then(() => {
if (props.freezeAfterPosted) { if (props.freezeAfterPosted) {
@ -1201,6 +1211,7 @@ onMounted(() => {
expiresAt: init.poll.expiresAt ? (new Date(init.poll.expiresAt)).getTime() : null, expiresAt: init.poll.expiresAt ? (new Date(init.poll.expiresAt)).getTime() : null,
expiredAfter: null, expiredAfter: null,
}; };
if (props.editId) initialPoll.value = poll.value;
} }
if (init.visibleUserIds) { if (init.visibleUserIds) {
misskeyApi('users/show', { userIds: init.visibleUserIds }).then(users => { misskeyApi('users/show', { userIds: init.visibleUserIds }).then(users => {

View file

@ -536,3 +536,7 @@ deleted: "Deleted"
enableProxyAccount: "Enable the proxy account." 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." 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