mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 09:15:33 +03:00
Fix toast showing even when canceling a boost/unboost confirmation
This commit is contained in:
parent
8ce8e06913
commit
18b00b2b7a
1 changed files with 9 additions and 4 deletions
|
@ -300,7 +300,8 @@ function Status({
|
|||
|
||||
const boostStatus = async () => {
|
||||
if (!sameInstance || !authenticated) {
|
||||
return alert(unauthInteractionErrorMessage);
|
||||
alert(unauthInteractionErrorMessage);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (!reblogged) {
|
||||
|
@ -314,7 +315,7 @@ function Status({
|
|||
}
|
||||
const yes = confirm(confirmText);
|
||||
if (!yes) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Optimistic
|
||||
|
@ -326,14 +327,17 @@ function Status({
|
|||
if (reblogged) {
|
||||
const newStatus = await masto.v1.statuses.unreblog(id);
|
||||
saveStatus(newStatus, instance);
|
||||
return true;
|
||||
} else {
|
||||
const newStatus = await masto.v1.statuses.reblog(id);
|
||||
saveStatus(newStatus, instance);
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// Revert optimistism
|
||||
states.statuses[sKey] = status;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -450,9 +454,10 @@ function Status({
|
|||
<MenuItem
|
||||
onClick={async () => {
|
||||
try {
|
||||
await boostStatus();
|
||||
if (!isSizeLarge)
|
||||
const done = await boostStatus();
|
||||
if (!isSizeLarge && done) {
|
||||
showToast(reblogged ? 'Unboosted' : 'Boosted');
|
||||
}
|
||||
} catch (e) {}
|
||||
}}
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue