mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-21 21:29:20 +01: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 () => {
|
const boostStatus = async () => {
|
||||||
if (!sameInstance || !authenticated) {
|
if (!sameInstance || !authenticated) {
|
||||||
return alert(unauthInteractionErrorMessage);
|
alert(unauthInteractionErrorMessage);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!reblogged) {
|
if (!reblogged) {
|
||||||
|
@ -314,7 +315,7 @@ function Status({
|
||||||
}
|
}
|
||||||
const yes = confirm(confirmText);
|
const yes = confirm(confirmText);
|
||||||
if (!yes) {
|
if (!yes) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Optimistic
|
// Optimistic
|
||||||
|
@ -326,14 +327,17 @@ function Status({
|
||||||
if (reblogged) {
|
if (reblogged) {
|
||||||
const newStatus = await masto.v1.statuses.unreblog(id);
|
const newStatus = await masto.v1.statuses.unreblog(id);
|
||||||
saveStatus(newStatus, instance);
|
saveStatus(newStatus, instance);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
const newStatus = await masto.v1.statuses.reblog(id);
|
const newStatus = await masto.v1.statuses.reblog(id);
|
||||||
saveStatus(newStatus, instance);
|
saveStatus(newStatus, instance);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
// Revert optimistism
|
// Revert optimistism
|
||||||
states.statuses[sKey] = status;
|
states.statuses[sKey] = status;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -450,9 +454,10 @@ function Status({
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
try {
|
try {
|
||||||
await boostStatus();
|
const done = await boostStatus();
|
||||||
if (!isSizeLarge)
|
if (!isSizeLarge && done) {
|
||||||
showToast(reblogged ? 'Unboosted' : 'Boosted');
|
showToast(reblogged ? 'Unboosted' : 'Boosted');
|
||||||
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue