feat(navigation): add external entry routing
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { AppStorage } from "@/data/storage/app/app_storage";
|
||||
import { AuthStorage } from "@/data/storage/auth/auth_storage";
|
||||
import { UserStorage } from "@/data/storage/user/user_storage";
|
||||
import { ROUTE_BUILDERS, ROUTES } from "@/router/routes";
|
||||
import { ROUTES } from "@/router/routes";
|
||||
import { todayString, UrlLauncherUtil } from "@/utils";
|
||||
|
||||
export async function resolveExternalBrowserPromptEligibility(): Promise<{
|
||||
@@ -27,42 +27,31 @@ export function recordExternalBrowserPromptShown(
|
||||
export async function openChatInExternalBrowser(): Promise<void> {
|
||||
const authStorage = AuthStorage.getInstance();
|
||||
const userStorage = UserStorage.getInstance();
|
||||
const [deviceIdR, facebookIdR, avatarUrlR] = await Promise.all([
|
||||
authStorage.getDeviceId(),
|
||||
authStorage.getFacebookId(),
|
||||
userStorage.getAvatarUrl(),
|
||||
]);
|
||||
const [deviceIdR, facebookIdR, facebookAppIdR, avatarUrlR] =
|
||||
await Promise.all([
|
||||
authStorage.getDeviceId(),
|
||||
authStorage.getFacebookId(),
|
||||
authStorage.getFacebookAppId(),
|
||||
userStorage.getAvatarUrl(),
|
||||
]);
|
||||
|
||||
const deviceId = deviceIdR.success ? deviceIdR.data : null;
|
||||
const facebookId = facebookIdR.success ? facebookIdR.data : null;
|
||||
const facebookAppId = facebookAppIdR.success ? facebookAppIdR.data : null;
|
||||
const avatarUrl = avatarUrlR.success ? avatarUrlR.data : null;
|
||||
|
||||
if (deviceId && facebookId) {
|
||||
UrlLauncherUtil.openUrlWithExternalBrowser(
|
||||
ROUTE_BUILDERS.chatDeviceId(deviceId),
|
||||
{
|
||||
queryParams: {
|
||||
fbid: facebookId,
|
||||
...(avatarUrl ? { avatarUrl } : {}),
|
||||
},
|
||||
UrlLauncherUtil.openUrlWithExternalBrowser(ROUTES.externalEntry, {
|
||||
queryParams: {
|
||||
target: "chat",
|
||||
deviceId,
|
||||
fbid: facebookId,
|
||||
...(facebookAppId ? { fb_app_id: facebookAppId } : {}),
|
||||
...(avatarUrl ? { avatarUrl } : {}),
|
||||
},
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
UrlLauncherUtil.openUrlWithExternalBrowser(ROUTES.splash);
|
||||
}
|
||||
|
||||
export async function persistExternalBrowserChatDeepLink(input: {
|
||||
deviceId: string;
|
||||
facebookId?: string | null;
|
||||
avatarUrl?: string | null;
|
||||
}): Promise<void> {
|
||||
await AuthStorage.getInstance().setDeviceId(input.deviceId);
|
||||
if (input.facebookId && input.facebookId.length > 0) {
|
||||
await AuthStorage.getInstance().setFacebookId(input.facebookId);
|
||||
}
|
||||
if (input.avatarUrl && input.avatarUrl.length > 0) {
|
||||
await UserStorage.getInstance().setAvatarUrl(input.avatarUrl);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user