Skip to content

Commit

Permalink
nit: fix autostart not working
Browse files Browse the repository at this point in the history
### What does this PR do?

Fixes autostart not working correctly.

This bug occurs during onMount when ProviderConfigured.svelte is loaded
and does runProvider without checking the autostart configuration.

Very small change / nit.

### Screenshot/screencast of this PR

<!-- Please include a screenshot or a screencast explaining what is doing this PR -->

### What issues does this PR fix or reference?

<!-- Please include any related issue from Podman Desktop repository (or from another issue tracker).
-->

Fixes #2781

### How to test this PR?

1. Disable autostart
2. Stop podman machine
3. Exit PD
4. Start PD, it should still stay stopped.

<!-- Please explain steps to reproduce -->

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
  • Loading branch information
cdrage committed Jun 20, 2023
1 parent 2e49286 commit d09f911
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Empty file added kind
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ import { beforeAll, test, vi } from 'vitest';
import { verifyStatus } from './ProviderStatusTestHelper.spec';
import ProviderConfigured from '/@/lib/dashboard/ProviderConfigured.svelte';

// fake the window.events object
beforeAll(() => {
(window as any).startProvider = vi.fn();

// mock that autostart is configured as true
(window.getConfigurationValue as unknown) = (_key: string) => {
return true;
};

// fake the window.events object
(window.events as unknown) = {
receive: (_channel: string, func: any) => {
func();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ async function runProvider() {
runInProgress = false;
}
onMount(() => {
onMount(async () => {
// Get the autostart configuration setting. If it's disabled, we do *not* want to start the current container provider.
const autostart = await window.getConfigurationValue<boolean>('preferences.engine.autostart');
if (!autostart) {
runAtStart = false;
}
if (runAtStart) {
runProvider();
}
Expand Down

0 comments on commit d09f911

Please sign in to comment.