2023-12-01 11:52:41 +01:00
|
|
|
import * as blueslip from "./blueslip";
|
|
|
|
import * as channel from "./channel";
|
2024-02-13 02:08:16 +01:00
|
|
|
import {current_user} from "./state_data";
|
2024-05-10 15:37:43 +02:00
|
|
|
import type {OnboardingStep} from "./state_data";
|
2023-12-02 13:34:05 +01:00
|
|
|
|
2024-02-24 20:09:41 +01:00
|
|
|
export const ONE_TIME_NOTICES_TO_DISPLAY = new Set<string>();
|
2023-12-01 11:52:41 +01:00
|
|
|
|
2024-02-24 20:09:41 +01:00
|
|
|
export function post_onboarding_step_as_read(onboarding_step_name: string): void {
|
|
|
|
void channel.post({
|
2023-12-01 11:52:41 +01:00
|
|
|
url: "/json/users/me/onboarding_steps",
|
|
|
|
data: {onboarding_step: onboarding_step_name},
|
|
|
|
error(err) {
|
|
|
|
if (err.readyState !== 0) {
|
|
|
|
blueslip.error("Failed to fetch onboarding steps", {
|
|
|
|
readyState: err.readyState,
|
|
|
|
status: err.status,
|
|
|
|
body: err.responseText,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2023-12-02 11:30:35 +01:00
|
|
|
|
2024-06-03 09:27:36 +02:00
|
|
|
export function update_onboarding_steps_to_display(onboarding_steps: OnboardingStep[]): void {
|
2023-12-02 13:34:05 +01:00
|
|
|
ONE_TIME_NOTICES_TO_DISPLAY.clear();
|
|
|
|
|
|
|
|
for (const onboarding_step of onboarding_steps) {
|
|
|
|
if (onboarding_step.type === "one_time_notice") {
|
|
|
|
ONE_TIME_NOTICES_TO_DISPLAY.add(onboarding_step.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-24 20:09:41 +01:00
|
|
|
export function initialize(): void {
|
2024-06-03 09:27:36 +02:00
|
|
|
update_onboarding_steps_to_display(current_user.onboarding_steps);
|
2023-12-02 13:34:05 +01:00
|
|
|
}
|