mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-09 16:53:36 -05:00
Mark link as trusted when opening, fixes #331.
This commit is contained in:
parent
40d95025b5
commit
14e749b65b
2 changed files with 4 additions and 3 deletions
|
@ -106,7 +106,7 @@ export const IntermediateContext = createContext({
|
|||
});
|
||||
|
||||
export const IntermediateActionsContext = createContext<{
|
||||
openLink: (href?: string) => boolean;
|
||||
openLink: (href?: string, trusted?: boolean) => boolean;
|
||||
openScreen: (screen: Screen) => void;
|
||||
writeClipboard: (text: string) => void;
|
||||
}>({
|
||||
|
@ -130,7 +130,7 @@ export default function Intermediate(props: Props) {
|
|||
|
||||
const actions = useMemo(() => {
|
||||
return {
|
||||
openLink: (href?: string) => {
|
||||
openLink: (href?: string, trusted?: boolean) => {
|
||||
const link = determineLink(href);
|
||||
|
||||
switch (link.type) {
|
||||
|
@ -145,6 +145,7 @@ export default function Intermediate(props: Props) {
|
|||
case "external": {
|
||||
const { trustedLinks } = getState();
|
||||
if (
|
||||
!trusted &&
|
||||
!trustedLinks.domains?.includes(link.url.hostname)
|
||||
) {
|
||||
openScreen({
|
||||
|
|
|
@ -22,7 +22,7 @@ export function ExternalLinkModal({ onClose, link }: Props) {
|
|||
actions={[
|
||||
{
|
||||
onClick: () => {
|
||||
openLink(link);
|
||||
openLink(link, true);
|
||||
onClose();
|
||||
},
|
||||
confirmation: true,
|
||||
|
|
Loading…
Reference in a new issue