mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Remove direct dependency of url-parse
This commit is contained in:
@ -21,6 +21,7 @@ import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import * as AuthSession from 'expo-auth-session'
|
||||
import * as Crypto from 'expo-crypto'
|
||||
import { Image } from 'expo-image'
|
||||
import * as Linking from 'expo-linking'
|
||||
import * as WebBrowser from 'expo-web-browser'
|
||||
import { debounce } from 'lodash'
|
||||
import React, { RefObject, useCallback, useState } from 'react'
|
||||
@ -28,7 +29,6 @@ import { Trans, useTranslation } from 'react-i18next'
|
||||
import { Alert, KeyboardAvoidingView, Platform, TextInput, View } from 'react-native'
|
||||
import { ScrollView } from 'react-native-gesture-handler'
|
||||
import { fromByteArray } from 'react-native-quick-base64'
|
||||
import parse from 'url-parse'
|
||||
import CustomText from '../Text'
|
||||
|
||||
export interface Props {
|
||||
@ -51,7 +51,7 @@ const ComponentInstance: React.FC<Props> = ({
|
||||
const whitelisted: boolean =
|
||||
!!domain.length &&
|
||||
!!errorCode &&
|
||||
!!(parse(`https://${domain}/`).hostname === domain) &&
|
||||
!!(Linking.parse(`https://${domain}/`).hostname === domain) &&
|
||||
errorCode === 401
|
||||
|
||||
const instanceQuery = useInstanceQuery({
|
||||
@ -129,7 +129,7 @@ const ComponentInstance: React.FC<Props> = ({
|
||||
(instanceQuery.data as Mastodon.Instance_V2)?.domain ||
|
||||
instanceQuery.data?.account_domain ||
|
||||
((instanceQuery.data as Mastodon.Instance_V1)?.uri
|
||||
? parse((instanceQuery.data as Mastodon.Instance_V1).uri).hostname
|
||||
? Linking.parse((instanceQuery.data as Mastodon.Instance_V1).uri).hostname
|
||||
: undefined) ||
|
||||
(instanceQuery.data as Mastodon.Instance_V1)?.uri,
|
||||
'auth.account.avatar_static': avatar_static,
|
||||
|
||||
@ -2,9 +2,9 @@ import { displayMessage } from '@components/Message'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { QueryKeyTimeline, useTimelineMutation } from '@utils/queryHooks/timeline'
|
||||
import { getAccountStorage } from '@utils/storage/actions'
|
||||
import * as Linking from 'expo-linking'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Alert } from 'react-native'
|
||||
import parse from 'url-parse'
|
||||
|
||||
const menuInstance = ({
|
||||
status,
|
||||
@ -32,9 +32,9 @@ const menuInstance = ({
|
||||
|
||||
const menus: ContextMenu = []
|
||||
|
||||
const instance = parse(status.uri).hostname
|
||||
const instance = Linking.parse(status.uri).hostname
|
||||
|
||||
if (instance !== getAccountStorage.string('auth.domain')) {
|
||||
if (instance && instance !== getAccountStorage.string('auth.domain')) {
|
||||
menus.push([
|
||||
{
|
||||
type: 'item',
|
||||
|
||||
Reference in New Issue
Block a user