Skip to content

Commit 02f91bc

Browse files
committed
fix: modified universal link
1 parent 5e581e9 commit 02f91bc

File tree

8 files changed

+103
-86
lines changed

8 files changed

+103
-86
lines changed
Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1 @@
1-
{
2-
"applinks": {
3-
"apps": [],
4-
"details": [
5-
{
6-
"appIDs": [
7-
"VHB67HRSZG.com.appflowy.appflowy.flutter"
8-
],
9-
"paths": [
10-
"*"
11-
],
12-
"components": [
13-
{
14-
"/": "/*"
15-
}
16-
]
17-
}
18-
]
19-
},
20-
"webcredentials": {
21-
"apps": [
22-
"VHB67HRSZG.com.appflowy.appflowy.flutter"
23-
]
24-
}
25-
}
1+
{"applinks":{"apps":[],"details":[{"appIDs":["VHB67HRSZG.com.appflowy.appflowy.flutter"],"paths":["/download","/download/*"],"components":[{"/":"/download","comment":"Matches any URL whose path starts with /download"},{"/":"/download/*","comment":"Matches any URL whose path starts with /download/"}]}]},"webcredentials":{"apps":["VHB67HRSZG.com.appflowy.appflowy.flutter"]}}

frontend/appflowy_web_app/public/.well-known/assetlinks.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"package_name": "io.appflowy.appflowy",
99
"sha256_cert_fingerprints": [
1010
"19:13:85:33:DB:B3:A2:FD:65:2F:61:D7:F2:35:95:79:FE:6E:CC:B5:AC:94:AA:02:9E:BE:E7:0E:02:6B:45:FF"
11-
]
11+
],
12+
"path_prefix": "/download"
1213
}
1314
}
1415
]

frontend/appflowy_web_app/src/components/login/Login.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React from 'react';
55
import { ReactComponent as Logo } from '@/assets/logo.svg';
66
import { useTranslation } from 'react-i18next';
77

8-
export function Login({ redirectTo }: { redirectTo: string }) {
8+
export function Login ({ redirectTo }: { redirectTo: string }) {
99
const { t } = useTranslation();
1010

1111
return (
@@ -27,11 +27,19 @@ export function Login({ redirectTo }: { redirectTo: string }) {
2727
}
2828
>
2929
<span>{t('web.signInAgreement')} </span>
30-
<a href={'https://appflowy.io/terms'} target={'_blank'} className={'text-fill-default underline'}>
30+
<a
31+
href={'https://appflowy.io/terms'}
32+
target={'_blank'}
33+
className={'text-fill-default underline'}
34+
>
3135
{t('web.termOfUse')}
3236
</a>{' '}
3337
{t('web.and')}{' '}
34-
<a href={'https://appflowy.io/privacy'} target={'_blank'} className={'text-fill-default underline'}>
38+
<a
39+
href={'https://appflowy.io/privacy'}
40+
target={'_blank'}
41+
className={'text-fill-default underline'}
42+
>
3543
{t('web.privacyPolicy')}
3644
</a>
3745
.

frontend/appflowy_web_app/src/components/main/App.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,35 @@ const AppMain = withAppWrapper(() => {
2020
<Routes>
2121
<Route
2222
path={'/:namespace/:publishName'}
23-
element={<PublishPage/>}
23+
element={<PublishPage />}
2424
/>
2525
<Route
2626
path={'/login'}
27-
element={<Suspense><LoginPage/></Suspense>}
27+
element={<Suspense><LoginPage /></Suspense>}
2828
/>
2929
<Route
3030
path={AUTH_CALLBACK_PATH}
31-
element={<LoginAuth/>}
31+
element={<LoginAuth />}
3232
/>
3333
<Route
3434
path="/404"
35-
element={<NotFound/>}
35+
element={<NotFound />}
3636
/>
3737
<Route
3838
path="/after-payment"
39-
element={<Suspense><AfterPaymentPage/></Suspense>}
39+
element={<Suspense><AfterPaymentPage /></Suspense>}
4040
/>
4141
<Route
4242
path="/as-template"
43-
element={<Suspense><AsTemplatePage/></Suspense>}
43+
element={<Suspense><AsTemplatePage /></Suspense>}
4444
/>
4545
<Route
4646
path="/accept-invitation"
47-
element={<Suspense><AcceptInvitationPage/></Suspense>}
47+
element={<Suspense><AcceptInvitationPage /></Suspense>}
4848
/>
4949
<Route
5050
path={'/import'}
51-
element={<Suspense><ImportPage/></Suspense>}
51+
element={<Suspense><ImportPage /></Suspense>}
5252
/>
5353
<Route
5454
path="/"
@@ -61,28 +61,23 @@ const AppMain = withAppWrapper(() => {
6161
path="/app/*"
6262
element={
6363
<Suspense>
64-
<AppRouter/>
64+
<AppRouter />
6565
</Suspense>
6666
}
6767
/>
6868
<Route
6969
path="*"
70-
element={<NotFound/>}
70+
element={<NotFound />}
7171
/>
7272
</Routes>
7373
);
7474
});
7575

76-
function App() {
77-
const path = window.location.pathname;
78-
79-
if (path.startsWith('/.well-known')) {
80-
return null;
81-
}
76+
function App () {
8277

8378
return (
8479
<BrowserRouter>
85-
<AppMain/>
80+
<AppMain />
8681
</BrowserRouter>
8782
);
8883
}

frontend/appflowy_web_app/src/components/quick-note/AddNote.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { QuickNote } from '@/application/types';
55
import { Button, CircularProgress } from '@mui/material';
66
import { useTranslation } from 'react-i18next';
77

8-
function AddNote({
8+
function AddNote ({
99
onEnterNote,
1010
onAdd,
1111
}: {
@@ -27,9 +27,10 @@ function AddNote({
2727
<Button
2828
size={'small'}
2929
color={'inherit'}
30-
startIcon={loading ? <CircularProgress className={'w-4 h-4'}/> : <AddIcon className={'w-4 h-4'}/>}
30+
startIcon={loading ? <CircularProgress size={16} /> : <AddIcon className={'w-4 h-4'} />}
3131
onClick={handleAdd}
32-
className={'justify-start w-full'}>
32+
className={'justify-start w-full'}
33+
>
3334
{t('quickNote.addNote')}
3435
</Button>
3536
</>

frontend/appflowy_web_app/src/components/quick-note/QuickNote.tsx

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import CircularProgress from '@mui/material/CircularProgress';
12
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
23
import { IconButton, Tooltip, Zoom, Snackbar, Portal } from '@mui/material';
34
import { ReactComponent as EditIcon } from '@/assets/edit.svg';
@@ -16,7 +17,7 @@ import { getPopoverPosition, setPopoverPosition } from '@/components/quick-note/
1617
import Note from '@/components/quick-note/Note';
1718

1819
const PAPER_SIZE = [480, 396];
19-
const Transition = React.forwardRef(function Transition(
20+
const Transition = React.forwardRef(function Transition (
2021
props: TransitionProps & {
2122
children: React.ReactElement;
2223
},
@@ -33,7 +34,7 @@ enum QuickNoteRoute {
3334
LIST = 'list',
3435
}
3536

36-
export function QuickNote() {
37+
export function QuickNote () {
3738
const { t } = useTranslation();
3839
const modifier = useMemo(() => createHotKeyLabel(HOT_KEY_NAME.QUICK_NOTE), []);
3940
const [open, setOpen] = React.useState(false);
@@ -197,6 +198,7 @@ export function QuickNote() {
197198
useEffect(() => {
198199
resetPosition();
199200
}, [resetPosition]);
201+
const [loading, setLoading] = React.useState(false);
200202

201203
const buttonRef = useRef<HTMLButtonElement>(null);
202204
const handleOpen = useCallback(async (forceCreate?: boolean) => {
@@ -217,7 +219,7 @@ export function QuickNote() {
217219
} : prev);
218220
}
219221

220-
await initNoteList();
222+
void initNoteList();
221223

222224
if (route === QuickNoteRoute.LIST || forceCreate) {
223225
await handleAdd();
@@ -232,14 +234,18 @@ export function QuickNote() {
232234
e.stopPropagation();
233235
e.preventDefault();
234236

237+
if (loading) return;
235238
void (async () => {
239+
setLoading(true);
236240
try {
237241
await handleOpen(true);
238242
// eslint-disable-next-line
239243
} catch (e: any) {
240244
console.error(e);
241245
handleOpenToast(e.message);
242246
}
247+
248+
setLoading(false);
243249
})();
244250
} else if (createHotkey(HOT_KEY_NAME.ESCAPE)(e)) {
245251
handleClose();
@@ -251,7 +257,7 @@ export function QuickNote() {
251257
return () => {
252258
document.removeEventListener('keydown', handleKeyDown);
253259
};
254-
}, [handleOpen, handleOpenToast]);
260+
}, [handleOpen, handleOpenToast, loading]);
255261

256262
const handleMouseDown = (event: React.MouseEvent) => {
257263
if (!position) return;
@@ -393,7 +399,8 @@ export function QuickNote() {
393399
expand={expand}
394400
onToggleExpand={handleToggleExpand}
395401
onClose={handleClose}
396-
onBack={handleBackList}/>
402+
onBack={handleBackList}
403+
/>
397404
);
398405
}
399406

@@ -423,26 +430,40 @@ export function QuickNote() {
423430

424431
return (
425432
<>
426-
<Tooltip title={
427-
<>
428-
<div>{t('quickNote.label')}</div>
429-
<div className={'text-xs text-text-caption'}>{modifier}</div>
430-
</>
431-
}>
433+
<Tooltip
434+
title={
435+
<>
436+
<div>{t('quickNote.label')}</div>
437+
<div className={'text-xs text-text-caption'}>{modifier}</div>
438+
</>
439+
}
440+
>
432441
<IconButton
433442
ref={buttonRef}
434443
size={'small'}
435-
onClick={e => {
444+
onClick={async (e) => {
436445
e.currentTarget.blur();
437446
if (open) {
438447
handleClose();
439448
return;
440449
}
441450

442-
void handleOpen();
451+
try {
452+
setLoading(true);
453+
await handleOpen();
454+
// eslint-disable-next-line
455+
} catch (e: any) {
456+
console.error(e);
457+
handleOpenToast(e.message);
458+
}
459+
460+
setLoading(false);
461+
443462
}}
463+
disabled={loading}
444464
>
445-
<EditIcon/>
465+
{loading ? <CircularProgress size={16} /> :
466+
<EditIcon />}
446467
</IconButton>
447468
</Tooltip>
448469
<Popover
@@ -481,21 +502,24 @@ export function QuickNote() {
481502
onClose={handleClose}
482503
keepMounted={true}
483504
>
484-
<ToastContext.Provider value={{
485-
onOpen: handleOpenToast,
486-
onClose: () => {
487-
setToastMessage('');
488-
setOpenToast(false);
489-
},
490-
open: openToast,
491-
}}>
505+
<ToastContext.Provider
506+
value={{
507+
onOpen: handleOpenToast,
508+
onClose: () => {
509+
setToastMessage('');
510+
setOpenToast(false);
511+
},
512+
open: openToast,
513+
}}
514+
>
492515
<div
493516
onMouseDown={handleMouseDown}
494517
style={{
495518
cursor: isDragging ? 'grabbing' : 'grab',
496519
}}
497520

498-
className={'bg-note-header py-2 px-5 flex items-center justify-between gap-5 h-[44px] w-full'}>
521+
className={'bg-note-header py-2 px-5 flex items-center justify-between gap-5 h-[44px] w-full'}
522+
>
499523
<div className={'flex-1 overflow-hidden w-full'}>{renderHeader()}</div>
500524
</div>
501525
<div
@@ -506,10 +530,12 @@ export function QuickNote() {
506530
<>
507531
<Note
508532
onAdd={handleAddedNote}
509-
onEnterNote={handleEnterNote} note={currentNote}
533+
onEnterNote={handleEnterNote}
534+
note={currentNote}
510535
onUpdateData={(data) => {
511536
handleUpdateNodeData(currentNote.id, data);
512-
}}/>
537+
}}
538+
/>
513539
</> : <NoteList
514540
onAdd={handleAddedNote}
515541
onScroll={handleScrollList}

frontend/appflowy_web_app/src/utils/open_schema.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { androidDownloadLink, desktopDownloadLink, iosDownloadLink, openAppFlowySchema } from '@/utils/url';
1+
import { androidDownloadLink, desktopDownloadLink, openAppFlowySchema } from '@/utils/url';
22

33
type OS = 'ios' | 'android' | 'other';
44

@@ -101,20 +101,30 @@ export const openAppOrDownload = (config: AppConfig): void => {
101101
};
102102
};
103103

104-
export function openOnly(schema?: string) {
104+
export function openOnly (schema?: string) {
105105

106106
return openAppOrDownload({
107107
appScheme: schema || openAppFlowySchema,
108108
});
109109
}
110110

111-
export function openOrDownload(schema?: string) {
111+
export function openOrDownload (schema?: string) {
112112
const os = getOS();
113-
114-
const downloadUrl = os === 'ios' ? iosDownloadLink : os === 'android' ? androidDownloadLink : desktopDownloadLink;
113+
114+
if (os === 'ios' || os === 'android') {
115+
const universalLink = 'https://appflowy.io/download';
116+
const intentUrl = `intent://appflowy.io/download#Intent;` +
117+
'scheme=https;' +
118+
'package=io.appflowy.app;' +
119+
`S.browser_fallback_url=${encodeURIComponent(androidDownloadLink)};` +
120+
'end';
121+
122+
window.location.href = os === 'ios' ? universalLink : intentUrl;
123+
return;
124+
}
115125

116126
return openAppOrDownload({
117127
appScheme: schema || openAppFlowySchema,
118-
downloadUrl,
128+
downloadUrl: desktopDownloadLink,
119129
});
120130
}

0 commit comments

Comments
 (0)