Skip to content

Commit

Permalink
fix(core): do not show open-in-app in mobile web browser (toeverythin…
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Nov 4, 2024
1 parent d35a9cf commit de7b1ff
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
10 changes: 6 additions & 4 deletions packages/frontend/apps/web/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { Telemetry } from '@affine/core/components/telemetry';
import { router } from '@affine/core/desktop/router';
import { configureCommonModules } from '@affine/core/modules';
import { I18nProvider } from '@affine/core/modules/i18n';
import { configureOpenInApp } from '@affine/core/modules/open-in-app';
import { WebOpenInAppGuard } from '@affine/core/modules/open-in-app/views/open-in-app-guard';
import {
configureOpenInApp,
OpenInAppGuard,
} from '@affine/core/modules/open-in-app';
import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage';
import { CustomThemeModifier } from '@affine/core/modules/theme-editor';
import { PopupWindowProvider } from '@affine/core/modules/url';
Expand Down Expand Up @@ -78,13 +80,13 @@ export function App() {
<Telemetry />
<CustomThemeModifier />
<GlobalLoading />
<WebOpenInAppGuard>
<OpenInAppGuard>
<RouterProvider
fallbackElement={<AppFallback key="RouterFallback" />}
router={router}
future={future}
/>
</WebOpenInAppGuard>
</OpenInAppGuard>
</AffineContext>
</I18nProvider>
</CacheProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const AppearanceSettings = () => {
{enableThemeEditor ? <ThemeEditorSetting /> : null}
</SettingWrapper>

{BUILD_CONFIG.isWeb ? (
{BUILD_CONFIG.isWeb && !environment.isMobile ? (
<SettingWrapper title={t['com.affine.setting.appearance.links']()}>
<SettingRow
name={t['com.affine.setting.appearance.open-in-app']()}
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/core/src/modules/open-in-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { OpenInAppService } from './services';

export * from './services';
export * from './utils';
export * from './views/open-in-app-guard';

export const configureOpenInApp = (framework: Framework) => {
framework.service(OpenInAppService, [GlobalState, WorkspacesService]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { assertExists } from '@blocksuite/affine/global/utils';
import { useLiveData, useService } from '@toeverything/infra';
import { useCallback, useEffect } from 'react';
import { Fragment, useCallback, useEffect } from 'react';

import { OpenInAppService } from '../services';
import { OpenInAppPage } from './open-in-app-page';

/**
* Web only guard to open the URL in desktop app for different conditions
*/
export const WebOpenInAppGuard = ({
children,
}: {
children: React.ReactNode;
}) => {
const WebOpenInAppGuard = ({ children }: { children: React.ReactNode }) => {
assertExists(
BUILD_CONFIG.isWeb,
'WebOpenInAppGuard should only be used in web'
Expand All @@ -36,9 +32,13 @@ export const WebOpenInAppGuard = ({
return null;
}

return shouldOpenInApp ? (
return shouldOpenInApp && !environment.isMobile ? (
<OpenInAppPage openHereClicked={onOpenHere} />
) : (
children
);
};

export const OpenInAppGuard = environment.isMobile
? Fragment
: WebOpenInAppGuard;

0 comments on commit de7b1ff

Please sign in to comment.