Skip to content

Commit

Permalink
fix(profile): #1397 fix links not opening in app
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviomoceri committed Dec 4, 2023
1 parent 70b747c commit 867a90c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/ProfileLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {
StyleProp,
StyleSheet,
ViewStyle,
Linking,
} from 'react-native';
import { useTranslation } from 'react-i18next';

import { Caption13Up, Text02M, Text02S } from '../styles/text';
import { TrashIcon } from '../styles/icons';
import { LocalLink } from '../store/types/slashtags';
import { openURL } from '../utils/helpers';
import { editLink, removeLink } from '../store/actions/slashtags';
import LabeledInput from './LabeledInput';
import Divider from './Divider';
Expand All @@ -33,6 +33,17 @@ const trimLink = (link: LocalLink): string => {
return trimmedUrl.replace('https://', '').replace('www.', '');
};

const openURL = async (url: string): Promise<boolean> => {
try {
await Linking.openURL(url);
return true;
} catch (err) {
console.log('Cannot open url: ', url);
console.error('Error opening URL: ', err);
return false;
}
};

const ProfileLinks = ({
links,
editable = false,
Expand Down

0 comments on commit 867a90c

Please sign in to comment.