The Welcome Home Screen: Return Button (#9089)
* Implement button to return to user onboarding screen * Add analytics events * Increase stability of lazy loading test
This commit is contained in:
parent
8db7766a40
commit
9eaf48b176
13 changed files with 241 additions and 28 deletions
|
@ -14,8 +14,9 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { ClientEvent, IMyDevice, Room } from "matrix-js-sdk/src/matrix";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
import DMRoomMap from "../utils/DMRoomMap";
|
||||
|
@ -33,18 +34,23 @@ export function useUserOnboardingContext(): UserOnboardingContext | null {
|
|||
|
||||
const cli = MatrixClientPeg.get();
|
||||
const handler = useCallback(async () => {
|
||||
const profile = await cli.getProfileInfo(cli.getUserId());
|
||||
try {
|
||||
const profile = await cli.getProfileInfo(cli.getUserId());
|
||||
|
||||
const myDevice = cli.getDeviceId();
|
||||
const devices = await cli.getDevices();
|
||||
const myDevice = cli.getDeviceId();
|
||||
const devices = await cli.getDevices();
|
||||
|
||||
const dmRooms = DMRoomMap.shared().getUniqueRoomsWithIndividuals() ?? {};
|
||||
setContext({
|
||||
avatar: profile?.avatar_url ?? null,
|
||||
myDevice,
|
||||
devices: devices.devices,
|
||||
dmRooms: dmRooms,
|
||||
});
|
||||
const dmRooms = DMRoomMap.shared().getUniqueRoomsWithIndividuals() ?? {};
|
||||
setContext({
|
||||
avatar: profile?.avatar_url ?? null,
|
||||
myDevice,
|
||||
devices: devices.devices,
|
||||
dmRooms: dmRooms,
|
||||
});
|
||||
} catch (e) {
|
||||
logger.warn("Could not load context for user onboarding task list: ", e);
|
||||
setContext(null);
|
||||
}
|
||||
}, [cli]);
|
||||
|
||||
useEventEmitter(cli, ClientEvent.AccountData, handler);
|
||||
|
|
|
@ -27,7 +27,7 @@ import { Notifier } from "../Notifier";
|
|||
import PosthogTrackers from "../PosthogTrackers";
|
||||
import { UseCase } from "../settings/enums/UseCase";
|
||||
import { useSettingValue } from "./useSettings";
|
||||
import { UserOnboardingContext, useUserOnboardingContext } from "./useUserOnboardingContext";
|
||||
import { UserOnboardingContext } from "./useUserOnboardingContext";
|
||||
|
||||
export interface UserOnboardingTask {
|
||||
id: string;
|
||||
|
@ -140,13 +140,12 @@ const tasks: InternalUserOnboardingTask[] = [
|
|||
},
|
||||
];
|
||||
|
||||
export function useUserOnboardingTasks(): [UserOnboardingTask[], UserOnboardingTask[]] {
|
||||
export function useUserOnboardingTasks(context: UserOnboardingContext): [UserOnboardingTask[], UserOnboardingTask[]] {
|
||||
const useCase = useSettingValue<UseCase | null>("FTUE.useCaseSelection") ?? UseCase.Skip;
|
||||
const relevantTasks = useMemo(
|
||||
() => tasks.filter(it => !it.relevant || it.relevant.includes(useCase)),
|
||||
[useCase],
|
||||
);
|
||||
const onboardingInfo = useUserOnboardingContext();
|
||||
const completedTasks = relevantTasks.filter(it => onboardingInfo && it.completed(onboardingInfo));
|
||||
const completedTasks = relevantTasks.filter(it => context && it.completed(context));
|
||||
return [completedTasks, relevantTasks.filter(it => !completedTasks.includes(it))];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue