perf: change params's name

This commit is contained in:
sevichecc 2023-04-16 19:27:07 +08:00
parent 51a30401ef
commit cb011ac123
Signed by untrusted user who does not match committer: SevicheCC
GPG key ID: C577000000000000

View file

@ -74,23 +74,20 @@ export default function SimpleCommand(props: CommandProps) {
init(); init();
}, []); }, []);
const handleSubmit = async ({ spoiler_text, status, scheduled_at, visibility, files, description }: StatusForm) => { const handleSubmit = async (value: StatusForm) => {
try { try {
if (!status && !files) throw new Error("You might forget the content, right ? |・ω・)"); if (!value.status && !value.files) throw new Error("You might forget the content, right ? |・ω・)");
showToast(Toast.Style.Animated, "Publishing to the Fediverse ... ᕕ( ᐛ )ᕗ"); showToast(Toast.Style.Animated, "Publishing to the Fediverse ... ᕕ( ᐛ )ᕗ");
const mediaIds = await Promise.all( const mediaIds = await Promise.all(
files?.map(async (file) => { value.files?.map(async (file) => {
const { id } = await apiServer.uploadAttachment({ file, description }); const { id } = await apiServer.uploadAttachment({ file, description: value.description });
return id; return id;
}) })
); );
const newStatus: Partial<Status> = { const newStatus: Partial<Status> = {
spoiler_text, ...value,
status,
scheduled_at,
visibility,
content_type: state.isMarkdown ? "text/markdown" : "text/plain", content_type: state.isMarkdown ? "text/markdown" : "text/plain",
media_ids: mediaIds, media_ids: mediaIds,
sensitive: state.sensitive, sensitive: state.sensitive,
@ -98,11 +95,9 @@ export default function SimpleCommand(props: CommandProps) {
const response = await apiServer.postNewStatus(newStatus); const response = await apiServer.postNewStatus(newStatus);
if (scheduled_at) { value.scheduled_at
showToast(Toast.Style.Success, "Scheduled", labelText(scheduled_at)); ? showToast(Toast.Style.Success, "Scheduled", labelText(value.scheduled_at))
} else { : showToast(Toast.Style.Success, "Status has been published (≧∇≦)/ ! ");
showToast(Toast.Style.Success, "Status has been published (≧∇≦)/ ! ");
}
setStatusInfo(response); setStatusInfo(response);
setState((prevState) => ({ setState((prevState) => ({