mirror of
https://github.com/Sevichecc/raycast-akkoma-extension.git
synced 2025-04-30 14:49:29 +08:00
perf: change params's name
This commit is contained in:
parent
51a30401ef
commit
cb011ac123
1 changed files with 8 additions and 13 deletions
|
@ -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) => ({
|
||||||
|
|
Loading…
Reference in a new issue