mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-04 13:19:48 +03:00
permalinks: better handling and onboarding, removing tiles too
This commit is contained in:
parent
335f8cb92f
commit
1c51b7d4ae
@ -43,6 +43,16 @@ const cards: OnboardingCardProps[] = [
|
|||||||
// }
|
// }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (window?.navigator?.registerProtocolHandler) {
|
||||||
|
cards.push({
|
||||||
|
title: 'Open Urbit-Native Links',
|
||||||
|
body: 'Enable your Urbit to open links you find in the wild',
|
||||||
|
button: 'Enable Link Handler',
|
||||||
|
color: '#82A6CA',
|
||||||
|
href: '/apps/grid/leap/system-preferences/interface'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
interface OnboardingCardProps {
|
interface OnboardingCardProps {
|
||||||
title: string;
|
title: string;
|
||||||
button: string;
|
button: string;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import React, { ReactElement } from 'react';
|
import React, { ReactElement } from 'react';
|
||||||
import useLaunchState from '~/logic/state/launch';
|
import useLaunchState from '~/logic/state/launch';
|
||||||
import { WeatherState } from '~/types';
|
import { WeatherState } from '~/types';
|
||||||
import BasicTile from './tiles/basic';
|
|
||||||
import ClockTile from './tiles/clock';
|
import ClockTile from './tiles/clock';
|
||||||
import CustomTile from './tiles/custom';
|
|
||||||
import WeatherTile from './tiles/weather';
|
import WeatherTile from './tiles/weather';
|
||||||
|
|
||||||
const Tiles = (): ReactElement => {
|
const Tiles = (): ReactElement => {
|
||||||
@ -16,16 +14,7 @@ const Tiles = (): ReactElement => {
|
|||||||
return tile.isShown;
|
return tile.isShown;
|
||||||
}).map((key) => {
|
}).map((key) => {
|
||||||
const tile = tileState[key];
|
const tile = tileState[key];
|
||||||
if ('basic' in tile.type) {
|
if ('custom' in tile.type) {
|
||||||
const basic = tile.type.basic;
|
|
||||||
return (
|
|
||||||
<BasicTile
|
|
||||||
key={key}
|
|
||||||
title={basic.title}
|
|
||||||
linkedUrl={basic.linkedUrl}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} else if ('custom' in tile.type) {
|
|
||||||
if (key === 'weather') {
|
if (key === 'weather') {
|
||||||
return (
|
return (
|
||||||
<WeatherTile key={key} />
|
<WeatherTile key={key} />
|
||||||
@ -35,14 +24,6 @@ const Tiles = (): ReactElement => {
|
|||||||
return (
|
return (
|
||||||
<ClockTile key={key} location={location} />
|
<ClockTile key={key} location={location} />
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<CustomTile
|
|
||||||
key={key}
|
|
||||||
tileImage={tile.type.custom.image}
|
|
||||||
linkedUrl={tile.type.custom.linkedUrl}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -224,8 +224,12 @@ function AppTile({ color, image, ...props }: AppTileProps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.navigator.registerProtocolHandler = undefined;
|
||||||
|
|
||||||
function AppPermalink({ link, ship, desk }: Omit<IAppPermalink, 'type'>) {
|
function AppPermalink({ link, ship, desk }: Omit<IAppPermalink, 'type'>) {
|
||||||
const treaty = useTreaty(ship, desk);
|
const treaty = useTreaty(ship, desk);
|
||||||
|
const hasProtocolHandling = Boolean(window?.navigator?.registerProtocolHandler);
|
||||||
|
const href = hasProtocolHandling ? link : `/apps/grid/perma?ext=${link}`;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!treaty) {
|
if (!treaty) {
|
||||||
@ -252,7 +256,7 @@ function AppPermalink({ link, ship, desk }: Omit<IAppPermalink, 'type'>) {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<ClampedText marginBottom={2} color="gray">{treaty?.info}</ClampedText>
|
<ClampedText marginBottom={2} color="gray">{treaty?.info}</ClampedText>
|
||||||
<Button as="a" href={link} primary alignSelf="start" display="inline-flex" marginTop="auto">Open App</Button>
|
<Button as="a" href={href} primary alignSelf="start" display="inline-flex" marginTop="auto">Open App</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user