Don't show multiple cancel buttons
This commit is contained in:
parent
c9ca5ee6e7
commit
8214aa42a1
@ -30,7 +30,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
const defaults = state.defaults;
|
const defaults = state.defaults;
|
||||||
|
|
||||||
let computeWeightsProgress: ComputeWeightsProgress | undefined;
|
let computeWeightsProgress: ComputeWeightsProgress | undefined;
|
||||||
let computing = false;
|
let computingWeights = false;
|
||||||
|
let checkingWeights = false;
|
||||||
|
let computingRetention = false;
|
||||||
|
$: computing = computingWeights || checkingWeights || computingRetention;
|
||||||
$: customSearch = `preset:"${$presetName}"`;
|
$: customSearch = `preset:"${$presetName}"`;
|
||||||
|
|
||||||
let computeRetentionProgress:
|
let computeRetentionProgress:
|
||||||
@ -47,11 +50,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
optimalRetentionRequest.daysToSimulate = 3650;
|
optimalRetentionRequest.daysToSimulate = 3650;
|
||||||
}
|
}
|
||||||
async function computeWeights(): Promise<void> {
|
async function computeWeights(): Promise<void> {
|
||||||
if (computing) {
|
if (computingWeights) {
|
||||||
await setWantsAbort({});
|
await setWantsAbort({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
computing = true;
|
computingWeights = true;
|
||||||
try {
|
try {
|
||||||
await runWithBackendProgress(
|
await runWithBackendProgress(
|
||||||
async () => {
|
async () => {
|
||||||
@ -76,16 +79,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
computing = false;
|
computingWeights = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkWeights(): Promise<void> {
|
async function checkWeights(): Promise<void> {
|
||||||
if (computing) {
|
if (checkingWeights) {
|
||||||
await setWantsAbort({});
|
await setWantsAbort({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
computing = true;
|
checkingWeights = true;
|
||||||
try {
|
try {
|
||||||
await runWithBackendProgress(
|
await runWithBackendProgress(
|
||||||
async () => {
|
async () => {
|
||||||
@ -116,16 +119,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
computing = false;
|
checkingWeights = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function computeRetention(): Promise<void> {
|
async function computeRetention(): Promise<void> {
|
||||||
if (computing) {
|
if (computingRetention) {
|
||||||
await setWantsAbort({});
|
await setWantsAbort({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
computing = true;
|
computingRetention = true;
|
||||||
try {
|
try {
|
||||||
await runWithBackendProgress(
|
await runWithBackendProgress(
|
||||||
async () => {
|
async () => {
|
||||||
@ -150,7 +153,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
computing = false;
|
computingRetention = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,26 +208,28 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
<summary>{tr.deckConfigComputeOptimalWeights()}</summary>
|
<summary>{tr.deckConfigComputeOptimalWeights()}</summary>
|
||||||
<input bind:value={customSearch} class="w-100 mb-1" />
|
<input bind:value={customSearch} class="w-100 mb-1" />
|
||||||
<button
|
<button
|
||||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
class="btn {computingWeights ? 'btn-warning' : 'btn-primary'}"
|
||||||
|
disabled={!computingWeights && computing}
|
||||||
on:click={() => computeWeights()}
|
on:click={() => computeWeights()}
|
||||||
>
|
>
|
||||||
{#if computing}
|
{#if computingWeights}
|
||||||
{tr.actionsCancel()}
|
{tr.actionsCancel()}
|
||||||
{:else}
|
{:else}
|
||||||
{tr.deckConfigComputeButton()}
|
{tr.deckConfigComputeButton()}
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
class="btn {checkingWeights ? 'btn-warning' : 'btn-primary'}"
|
||||||
|
disabled={!checkingWeights && computing}
|
||||||
on:click={() => checkWeights()}
|
on:click={() => checkWeights()}
|
||||||
>
|
>
|
||||||
{#if computing}
|
{#if checkingWeights}
|
||||||
{tr.actionsCancel()}
|
{tr.actionsCancel()}
|
||||||
{:else}
|
{:else}
|
||||||
{tr.deckConfigAnalyzeButton()}
|
{tr.deckConfigAnalyzeButton()}
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
{#if computing}<div>{computeWeightsProgressString}</div>{/if}
|
{#if checkingWeights}<div>{computeWeightsProgressString}</div>{/if}
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -251,10 +256,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
<br />
|
<br />
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
class="btn {computingRetention ? 'btn-warning' : 'btn-primary'}"
|
||||||
|
disabled={!computingRetention && computing}
|
||||||
on:click={() => computeRetention()}
|
on:click={() => computeRetention()}
|
||||||
>
|
>
|
||||||
{#if computing}
|
{#if computingRetention}
|
||||||
{tr.actionsCancel()}
|
{tr.actionsCancel()}
|
||||||
{:else}
|
{:else}
|
||||||
{tr.deckConfigComputeButton()}
|
{tr.deckConfigComputeButton()}
|
||||||
|
Loading…
Reference in New Issue
Block a user