Skip to content

Commit

Permalink
fix(ui/fonts): fix import font crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
pylixonly committed Sep 8, 2024
1 parent 98cf23e commit 13d3672
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/core/ui/settings/pages/Fonts/FontEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import { FontManifest, OldFontDefinition } from "@lib/addons/fonts/types";
import ColorManager from "@lib/addons/themes/colors/ColorManager";
import { findAssetId } from "@lib/api/assets";
import { useObservable } from "@lib/api/storage";
import { hideSheet, showSheet } from "@lib/ui/sheets";
import { safeFetch } from "@lib/utils";
import { NavigationNative } from "@metro/common";
import { ActionSheet, BottomSheetTitleHeader, Button, IconButton, Stack, TableRow, TableRowGroup, Text, TextInput } from "@metro/common/components";
import { findByPropsLazy } from "@metro/wrappers";
import { ErrorBoundary } from "@ui/components";
import { useMemo, useRef, useState } from "react";
import { ScrollView, View } from "react-native";

const actionSheet = findByPropsLazy("hideActionSheet");

function guessFontName(urls: string[]) {
const fileNames = urls.map(url => {
const { pathname } = new URL(url);
Expand Down Expand Up @@ -73,7 +71,7 @@ function RevengeFontsExtractor({ fonts, setName }: {

setName(fontName);
Object.assign(fonts, themeFonts);
actionSheet.hideActionSheet();
hideSheet("FontEditorActionSheet");
} catch (e) {
setError(String(e));
}
Expand Down Expand Up @@ -123,7 +121,7 @@ function JsonFontImporter({ fonts, setName, setId, setSource }: {

Object.assign(fonts, json.main);
})()
.then(() => actionSheet.hideActionSheet())
.then(() => hideSheet("FontEditorActionSheet"))
.catch(e => setError(String(e)))
.finally(() => setSaving(false));

Expand Down Expand Up @@ -172,14 +170,14 @@ function promptActionSheet(
fontEntries: Record<string, string>,
props: any
) {
actionSheet.openLazy(
showSheet(
"FontEditorActionSheet",
() => <ErrorBoundary>
<ActionSheet>
<BottomSheetTitleHeader title="Import Font" />
<Component fonts={fontEntries} {...props} />
</ActionSheet>
</ErrorBoundary>,
"FontEditorActionSheet"
</ErrorBoundary>
);
}

Expand Down

0 comments on commit 13d3672

Please sign in to comment.