feat: restore opt-in first-run onboarding

This commit is contained in:
vorotamoroz
2026-07-20 11:28:41 +00:00
parent f70779c352
commit 52e7bd25da
12 changed files with 511 additions and 40 deletions
@@ -1,8 +1,38 @@
import { type SetupManager, UserMode } from "@/modules/features/SetupManager";
import type { SetupFeatureHost } from "@/serviceFeatures/setupObsidian/types";
import { EVENT_REQUEST_OPEN_P2P_SETTINGS, EVENT_REQUEST_OPEN_SETUP_URI } from "@vrtmrz/livesync-commonlib/compat/events/coreEvents";
import {
EVENT_REQUEST_OPEN_P2P_SETTINGS,
EVENT_REQUEST_OPEN_SETUP_URI,
} from "@vrtmrz/livesync-commonlib/compat/events/coreEvents";
import { fireAndForget } from "@vrtmrz/livesync-commonlib/compat/common/utils";
import type { NecessaryServices } from "@vrtmrz/livesync-commonlib/compat/interfaces/ServiceModule";
import { $msg } from "@vrtmrz/livesync-commonlib/compat/common/i18n";
const ONBOARDING_NOTICE_DURATION_MS = 60_000;
export async function openOnboarding(setupManager: SetupManager) {
return await setupManager.startOnBoarding();
}
export function showOnboardingInvitation(host: NecessaryServices<"UI", never>, setupManager: SetupManager): void {
const message = `${$msg("Welcome to Self-hosted LiveSync")} ${$msg(
"We will now guide you through a few questions to simplify the synchronisation setup."
)} {HERE}`;
host.services.UI.confirm.askInPopup(
"initial-onboarding",
message,
(anchor) => {
anchor.href = "#";
anchor.classList.add("sls-onboarding-invitation-action");
anchor.textContent = $msg("Ui.SetupWizard.Invitation.Start");
anchor.addEventListener("click", (event) => {
event.preventDefault();
fireAndForget(() => openOnboarding(setupManager));
});
},
ONBOARDING_NOTICE_DURATION_MS
);
}
export async function openSetupURI(setupManager: SetupManager) {
await setupManager.onUseSetupURI(UserMode.Unknown);
@@ -17,6 +47,11 @@ export function useSetupManagerHandlersFeature(
setupManager: SetupManager
) {
host.services.appLifecycle.onLoaded.addHandler(() => {
host.services.API.addCommand({
id: "livesync-open-onboarding",
name: "Open onboarding wizard",
callback: () => fireAndForget(() => openOnboarding(setupManager)),
});
host.services.API.addCommand({
id: "livesync-opensetupuri",
name: "Use the copied setup URI (Formerly Open setup URI)",