Mark link as trusted when opening, fixes #331.

This commit is contained in:
Paul 2021-10-10 16:11:43 +01:00
parent 40d95025b5
commit 14e749b65b
2 changed files with 4 additions and 3 deletions

View file

@ -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({

View file

@ -22,7 +22,7 @@ export function ExternalLinkModal({ onClose, link }: Props) {
actions={[
{
onClick: () => {
openLink(link);
openLink(link, true);
onClose();
},
confirmation: true,