Reduce amount of requests done by the onboarding task list (#9194)

* Significantly reduce work of useUserOnboardingContext
* Wrap UserOnboardingButton to avoid unnecessary work when it's not shown
* Remove progress from user onboarding button
This commit is contained in:
Janne Mareike Koschinski 2022-08-22 13:48:54 +02:00 committed by GitHub
parent e8eefeb937
commit 94d292a6ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 117 additions and 81 deletions

View file

@ -47,8 +47,6 @@ interface InternalUserOnboardingTask extends UserOnboardingTask {
completed: (ctx: UserOnboardingContext) => boolean;
}
const hasOpenDMs = (ctx: UserOnboardingContext) => Boolean(Object.entries(ctx.dmRooms).length);
const onClickStartDm = (ev: ButtonEvent) => {
PosthogTrackers.trackInteraction("WebUserOnboardingTaskSendDm", ev);
defaultDispatcher.dispatch({ action: 'view_create_chat' });
@ -65,7 +63,7 @@ const tasks: InternalUserOnboardingTask[] = [
id: "find-friends",
title: _t("Find and invite your friends"),
description: _t("Its what youre here for, so lets get to it"),
completed: hasOpenDMs,
completed: (ctx: UserOnboardingContext) => ctx.hasDmRooms,
relevant: [UseCase.PersonalMessaging, UseCase.Skip],
action: {
label: _t("Find friends"),
@ -76,7 +74,7 @@ const tasks: InternalUserOnboardingTask[] = [
id: "find-coworkers",
title: _t("Find and invite your co-workers"),
description: _t("Get stuff done by finding your teammates"),
completed: hasOpenDMs,
completed: (ctx: UserOnboardingContext) => ctx.hasDmRooms,
relevant: [UseCase.WorkMessaging],
action: {
label: _t("Find people"),
@ -87,7 +85,7 @@ const tasks: InternalUserOnboardingTask[] = [
id: "find-community-members",
title: _t("Find and invite your community members"),
description: _t("Get stuff done by finding your teammates"),
completed: hasOpenDMs,
completed: (ctx: UserOnboardingContext) => ctx.hasDmRooms,
relevant: [UseCase.CommunityMessaging],
action: {
label: _t("Find people"),
@ -102,9 +100,7 @@ const tasks: InternalUserOnboardingTask[] = [
description: () => _t("Dont miss a thing by taking %(brand)s with you", {
brand: SdkConfig.get("brand"),
}),
completed: (ctx: UserOnboardingContext) => {
return Boolean(ctx.devices.filter(it => it.device_id !== ctx.myDevice).length);
},
completed: (ctx: UserOnboardingContext) => ctx.hasDevices,
action: {
label: _t("Download apps"),
onClick: (ev: ButtonEvent) => {
@ -117,7 +113,7 @@ const tasks: InternalUserOnboardingTask[] = [
id: "setup-profile",
title: _t("Set up your profile"),
description: _t("Make sure people know its really you"),
completed: (info: UserOnboardingContext) => Boolean(info.avatar),
completed: (ctx: UserOnboardingContext) => ctx.hasAvatar,
action: {
label: _t("Your profile"),
onClick: (ev: ButtonEvent) => {
@ -133,7 +129,7 @@ const tasks: InternalUserOnboardingTask[] = [
id: "permission-notifications",
title: _t("Turn on notifications"),
description: _t("Dont miss a reply or important message"),
completed: () => Notifier.isPossible(),
completed: (ctx: UserOnboardingContext) => ctx.hasNotificationsEnabled,
action: {
label: _t("Enable notifications"),
onClick: (ev: ButtonEvent) => {