fix(metro/common): polyfill url
This commit is contained in:
parent
d703120268
commit
59ffa77a3a
3 changed files with 24 additions and 9 deletions
|
|
@ -7,15 +7,15 @@ import { isThemeSupported } from "@lib/api/native/loader";
|
||||||
import { after, instead } from "@lib/api/patcher";
|
import { after, instead } from "@lib/api/patcher";
|
||||||
import { VD_PROXY_PREFIX, VD_THEMES_CHANNEL_ID } from "@lib/utils/constants";
|
import { VD_PROXY_PREFIX, VD_THEMES_CHANNEL_ID } from "@lib/utils/constants";
|
||||||
import { lazyDestructure } from "@lib/utils/lazy";
|
import { lazyDestructure } from "@lib/utils/lazy";
|
||||||
import { channels, url } from "@metro/common";
|
import { channels } from "@metro/common";
|
||||||
import { byMutableProp } from "@metro/filters";
|
import { byMutableProp } from "@metro/filters";
|
||||||
import { findExports } from "@metro/finders";
|
import { findExports } from "@metro/finders";
|
||||||
import { findByProps, findByPropsLazy } from "@metro/wrappers";
|
import { findByProps, findByPropsLazy } from "@metro/wrappers";
|
||||||
import { showToast } from "@ui/toasts";
|
import { showToast } from "@ui/toasts";
|
||||||
|
import { Linking } from "react-native";
|
||||||
|
|
||||||
const showSimpleActionSheet = findExports(byMutableProp("showSimpleActionSheet"));
|
const showSimpleActionSheet = findExports(byMutableProp("showSimpleActionSheet"));
|
||||||
const handleClick = findByPropsLazy("handleClick");
|
const handleClick = findByPropsLazy("handleClick");
|
||||||
const { openURL } = lazyDestructure(() => url);
|
|
||||||
const { getChannelId } = lazyDestructure(() => channels);
|
const { getChannelId } = lazyDestructure(() => channels);
|
||||||
const { getChannel } = lazyDestructure(() => findByProps("getChannel"));
|
const { getChannel } = lazyDestructure(() => findByProps("getChannel"));
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ export default () => {
|
||||||
confirmText: Strings.INSTALL,
|
confirmText: Strings.INSTALL,
|
||||||
cancelText: Strings.CANCEL,
|
cancelText: Strings.CANCEL,
|
||||||
secondaryConfirmText: Strings.OPEN_IN_BROWSER,
|
secondaryConfirmText: Strings.OPEN_IN_BROWSER,
|
||||||
onConfirmSecondary: () => openURL(url),
|
onConfirmSecondary: () => Linking.openURL(url),
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ import { BundleUpdaterManager } from "@lib/api/native/modules";
|
||||||
import { settings } from "@lib/api/settings";
|
import { settings } from "@lib/api/settings";
|
||||||
import { openAlert } from "@lib/ui/alerts";
|
import { openAlert } from "@lib/ui/alerts";
|
||||||
import { DISCORD_SERVER, GITHUB } from "@lib/utils/constants";
|
import { DISCORD_SERVER, GITHUB } from "@lib/utils/constants";
|
||||||
import { NavigationNative, url } from "@metro/common";
|
import { NavigationNative } from "@metro/common";
|
||||||
import { AlertActionButton, AlertActions, AlertModal, Stack, TableRow, TableRowGroup, TableSwitchRow } from "@metro/common/components";
|
import { AlertActionButton, AlertActions, AlertModal, Stack, TableRow, TableRowGroup, TableSwitchRow } from "@metro/common/components";
|
||||||
import { ScrollView } from "react-native";
|
import { Linking, ScrollView } from "react-native";
|
||||||
|
|
||||||
export default function General() {
|
export default function General() {
|
||||||
useProxy(settings);
|
useProxy(settings);
|
||||||
|
|
@ -48,13 +48,13 @@ export default function General() {
|
||||||
arrow={true}
|
arrow={true}
|
||||||
label={Strings.DISCORD_SERVER}
|
label={Strings.DISCORD_SERVER}
|
||||||
icon={<TableRow.Icon source={findAssetId("Discord")!} />}
|
icon={<TableRow.Icon source={findAssetId("Discord")!} />}
|
||||||
onPress={() => url.openDeeplink(DISCORD_SERVER)}
|
onPress={() => Linking.openURL(DISCORD_SERVER)}
|
||||||
/>
|
/>
|
||||||
<TableRow
|
<TableRow
|
||||||
arrow={true}
|
arrow={true}
|
||||||
label={Strings.GITHUB}
|
label={Strings.GITHUB}
|
||||||
icon={<TableRow.Icon source={findAssetId("img_account_sync_github_white")!} />}
|
icon={<TableRow.Icon source={findAssetId("img_account_sync_github_white")!} />}
|
||||||
onPress={() => url.openURL(GITHUB)}
|
onPress={() => Linking.openURL(GITHUB)}
|
||||||
/>
|
/>
|
||||||
</TableRowGroup>
|
</TableRowGroup>
|
||||||
<TableRowGroup title={Strings.ACTIONS}>
|
<TableRowGroup title={Strings.ACTIONS}>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { lazyDestructure } from "@lib/utils/lazy";
|
||||||
import { findByFilePathLazy, findByProps, findByPropsLazy } from "@metro/wrappers";
|
import { findByFilePathLazy, findByProps, findByPropsLazy } from "@metro/wrappers";
|
||||||
|
|
||||||
import type { Dispatcher } from "./types/flux";
|
import type { Dispatcher } from "./types/flux";
|
||||||
|
import { Linking } from "react-native";
|
||||||
|
|
||||||
export * as components from "./components";
|
export * as components from "./components";
|
||||||
|
|
||||||
|
|
@ -9,7 +10,21 @@ export * as components from "./components";
|
||||||
export const constants = findByPropsLazy("Fonts", "Permissions");
|
export const constants = findByPropsLazy("Fonts", "Permissions");
|
||||||
export const channels = findByPropsLazy("getVoiceChannelId");
|
export const channels = findByPropsLazy("getVoiceChannelId");
|
||||||
export const i18n = findByPropsLazy("Messages");
|
export const i18n = findByPropsLazy("Messages");
|
||||||
export const url = findByPropsLazy("openURL", "openDeeplink");
|
|
||||||
|
// Polyfill LinkingUtils
|
||||||
|
const openURL = (url: string) => Linking.openURL(url);
|
||||||
|
export const url = nativeModuleProxy.NativeLinkingModule || nativeModuleProxy.DCDLinkingManager ? {
|
||||||
|
openURL,
|
||||||
|
openDeeplink: openURL,
|
||||||
|
handleSupportedURL: openURL,
|
||||||
|
isDiscordConnectOauth2Deeplink: () => {
|
||||||
|
console.warn("url.isDiscordConnectOauth2Deeplink is not implemented and will always return false");
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
showLongPressUrlActionSheet: () => console.warn("url.showLongPressUrlActionSheet is not implemented"),
|
||||||
|
handleMessageLinking: findByFilePathLazy("modules/links/native/handleContentLinking.tsx", true),
|
||||||
|
} : findByPropsLazy("openURL", "openDeeplink");
|
||||||
|
|
||||||
export const clipboard = findByPropsLazy("setString", "getString", "hasString");
|
export const clipboard = findByPropsLazy("setString", "getString", "hasString");
|
||||||
export const assets = findByPropsLazy("registerAsset");
|
export const assets = findByPropsLazy("registerAsset");
|
||||||
export const invites = findByPropsLazy("acceptInviteAndTransitionToInviteChannel");
|
export const invites = findByPropsLazy("acceptInviteAndTransitionToInviteChannel");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue