import TableRowAssetIcon from '@revenge-mod/components/TableRowAssetIcon' import { AlertActionCreators } from '@revenge-mod/discord/actions' import { Design } from '@revenge-mod/discord/design' import { useEffect, useState } from 'react' import { ScrollView, useWindowDimensions } from 'react-native' import { LicenseFallbackURL } from '~/constants' import { Setting } from '../constants' import type { SettingsItem } from '@revenge-mod/discord/modules/settings' const RevengeLicenseSetting: SettingsItem = { parent: Setting.Revenge, IconComponent: () => , title: () => 'License', onPress: () => { AlertActionCreators.openAlert('revenge-license', ) }, type: 'pressable', } export default RevengeLicenseSetting const trimStart = (text: string) => text.replaceAll(/^ +/gm, '') function LicenseAlert() { const { height } = useWindowDimensions() const [license, setLicense] = useState(null) useEffect(() => { fetch(__BUILD_LICENSE_URL__) .then(response => { if (!response.ok) { throw new Error( `Failed to fetch license: ${response.statusText}`, ) } return response.text() }) .then(trimStart) .then(setLicense) .catch(() => { // Fallback to the hardcoded license URL fetch(LicenseFallbackURL) .then(response => response.text()) .then(trimStart) .then(setLicense) .catch(error => { console.error( 'Failed to fetch fallback license:', error, ) setLicense('Failed to load license.') }) }) }, []) return ( {license ?? 'Fetching...'} } actions={ } /> ) }