[Utils] Remove copyText (#39)

[Cleanup] Fix imports
This commit is contained in:
Jack 2023-03-20 16:11:27 -04:00 committed by GitHub
parent e000d8384c
commit 13cf5e6872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 19 deletions

1
src/def.d.ts vendored
View file

@ -369,7 +369,6 @@ interface VendettaObject {
HTTP_REGEX: RegExp;
};
utils: {
copyText: (content: string) => void;
findInReactTree: (tree: SearchTree, filter: SearchFilter) => any;
findInTree: (tree: SearchTree, filter: SearchFilter, options: FindInTreeOptions) => any;
safeFetch: (input: RequestInfo, options: RequestInit) => Promise<Response>;

View file

@ -1,11 +0,0 @@
import { clipboard } from "@metro/common";
// TODO: Remove/deprecate this, the clipboard module works the same way.
export default function copyText(content: string) {
try {
clipboard.setString(content);
} catch (e) {
throw new Error("Failed to set clipboard content.");
}
}

View file

@ -1,5 +1,4 @@
// Makes mass-importing utils cleaner, chosen over moving utils to one file
export { default as copyText } from "@utils/copyText";
export { default as findInReactTree } from "@utils/findInReactTree";
export { default as findInTree } from "@utils/findInTree";
export { default as safeFetch } from "@utils/safeFetch";

View file

@ -1,9 +1,8 @@
import { Asset } from "@types";
import { ReactNative as RN, stylesheet } from "@metro/common";
import { ReactNative as RN, stylesheet, clipboard } from "@metro/common";
import { showToast } from "@ui/toasts";
import { getAssetIDByName } from "@ui/assets";
import { Forms } from "@ui/components";
import copyText from "@lib/utils/copyText";
interface AssetDisplayProps {
asset: Asset;
@ -24,7 +23,7 @@ export default function AssetDisplay({ asset }: AssetDisplayProps) {
label={`${asset.name} - ${asset.id}`}
trailing={<RN.Image source={asset.id} style={styles.asset} />}
onPress={() => {
copyText(asset.name);
clipboard.setString(asset.name);
showToast("Copied asset name to clipboard.", getAssetIDByName("toast_copy_link"));
}}
/>

View file

@ -1,4 +1,4 @@
import { ReactNative as RN, clipboard, stylesheet } from "@metro/common";
import { ReactNative as RN, stylesheet, clipboard } from "@metro/common";
import { HTTP_REGEX } from "@lib/constants";
import { showInputAlert } from "@ui/alerts";
import { getAssetIDByName } from "@ui/assets";

View file

@ -1,7 +1,7 @@
import { clipboard } from "@metro/common";
import { getAssetIDByName } from "@ui/assets";
import { showToast } from "@ui/toasts";
import { Forms } from "@ui/components";
import copyText from "@utils/copyText";
interface VersionProps {
label: string;
@ -18,7 +18,7 @@ export default function Version({ label, version, icon }: VersionProps) {
leading={<FormRow.Icon source={getAssetIDByName(icon)} />}
trailing={<FormText>{version}</FormText>}
onPress={() => {
copyText(`${label} - ${version}`);
clipboard.setString(`${label} - ${version}`);
showToast("Copied version to clipboard.", getAssetIDByName("toast_copy_link"));
}}
/>