[Global] Tidy usage of native modules

This commit is contained in:
Beef 2023-04-05 20:40:17 +01:00
parent 10618ae217
commit aff1c83e94
9 changed files with 36 additions and 35 deletions

View file

@ -1,6 +1,7 @@
import { ButtonColors, Theme } from "@types";
import { ReactNative as RN, clipboard } from "@metro/common";
import { fetchTheme, removeTheme, selectTheme } from "@lib/themes";
import { BundleUpdaterManager } from "@lib/native";
import { getAssetIDByName } from "@ui/assets";
import { showConfirmationAlert } from "@ui/alerts";
import { showToast } from "@ui/toasts";
@ -13,7 +14,7 @@ interface ThemeCardProps {
async function selectAndReload(value: boolean, id: string) {
await selectTheme(value ? id : "default");
RN.NativeModules.BundleUpdaterManager.reload();
BundleUpdaterManager.reload();
}
export default function ThemeCard({ theme, index }: ThemeCardProps) {
@ -48,7 +49,7 @@ export default function ThemeCard({ theme, index }: ThemeCardProps) {
confirmText: "Reload",
cancelText: "Cancel",
confirmColor: ButtonColors.RED,
onConfirm: () => RN.NativeModules.BundleUpdaterManager.reload(),
onConfirm: () => BundleUpdaterManager.reload(),
})
} else {
showToast("Successfully refetched theme.", getAssetIDByName("toast_image_saved"));

View file

@ -4,6 +4,7 @@ import { Forms, Summary } from "@ui/components";
import { DISCORD_SERVER, GITHUB } from "@lib/constants";
import { getDebugInfo } from "@lib/debug";
import { useProxy } from "@lib/storage";
import { BundleUpdaterManager } from "@lib/native";
import settings from "@lib/settings";
import Version from "@ui/settings/components/Version";
import ErrorBoundary from "@ui/components/ErrorBoundary";
@ -102,7 +103,7 @@ export default function General() {
<FormRow
label="Reload Discord"
leading={<FormRow.Icon source={getAssetIDByName("ic_message_retry")} />}
onPress={() => RN.NativeModules.BundleUpdaterManager.reload()}
onPress={() => BundleUpdaterManager.reload()}
/>
<FormDivider />
<FormSwitchRow