* typescript and view component for permalink with user and message * Old post edited handling in permalink * Added test and update flag value to EnablePermalinkPreview * Added test for permalink_preview component * Added test for content/index.tsx for permalink * Addressed review comments * Unit test for missing file and review comments * Added test to check handlePostEdited permalink sync only calls one time only * Change TouchableOpacity to Pressable * When user not found fetch the user from the server * Removed the redundant test in the test for permalink_preview/index? * ts to tsx * Removed the circular dependency * Address review comments * displayname fallback * remove permalink when permalink post is deleted * UX review comments * Linter fixes * Test fixes * File attachment in permalink preview component * Fix the width and height of the image in permalink * Added gredient when exceeds height of permalink container * Minor * Updated tests * Minor * Review comments * Minor review comments * type fixes * Review comments * Minor * Mention ability in permalink preview * Support for external link in permalink * Handle device not connected update permalink post * test fixes * Address review comments * Minor * Merge fixes * Addressed review comments * Fix content.test.tsx after permalink branch merge - Updated test expectations to use embedData prop instead of post prop - Fixed assertions to match the new PermalinkPreview API - All content tests now pass * review comments * Review comments * Some more review comments * Minor * Fixed the undefined issue for opengraph component metadata * More fixes * type chech for site name * linter fixes * UX review and remove show more height not require * Fix tests * Review nitpick and fixes * Minor UX changes --------- Co-authored-by: yasserfaraazkhan <attitude3cena.yf@gmail.com>
23 lines
653 B
TypeScript
23 lines
653 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {useCallback} from 'react';
|
|
import {useIntl} from 'react-intl';
|
|
|
|
import {useServerUrl} from '@context/server';
|
|
import {openLink} from '@utils/url/links';
|
|
|
|
export const useExternalLinkHandler = (url?: string, siteURL?: string) => {
|
|
const intl = useIntl();
|
|
const serverUrl = useServerUrl();
|
|
|
|
return useCallback(() => {
|
|
if (!url || !serverUrl) {
|
|
return;
|
|
}
|
|
|
|
openLink(url, serverUrl, siteURL || '', intl);
|
|
}, [intl, url, serverUrl, siteURL]);
|
|
};
|
|
|
|
export default useExternalLinkHandler;
|