mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-25 16:40:58 -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<{
|
export const IntermediateActionsContext = createContext<{
|
||||||
openLink: (href?: string) => boolean;
|
openLink: (href?: string, trusted?: boolean) => boolean;
|
||||||
openScreen: (screen: Screen) => void;
|
openScreen: (screen: Screen) => void;
|
||||||
writeClipboard: (text: string) => void;
|
writeClipboard: (text: string) => void;
|
||||||
}>({
|
}>({
|
||||||
|
@ -130,7 +130,7 @@ export default function Intermediate(props: Props) {
|
||||||
|
|
||||||
const actions = useMemo(() => {
|
const actions = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
openLink: (href?: string) => {
|
openLink: (href?: string, trusted?: boolean) => {
|
||||||
const link = determineLink(href);
|
const link = determineLink(href);
|
||||||
|
|
||||||
switch (link.type) {
|
switch (link.type) {
|
||||||
|
@ -145,6 +145,7 @@ export default function Intermediate(props: Props) {
|
||||||
case "external": {
|
case "external": {
|
||||||
const { trustedLinks } = getState();
|
const { trustedLinks } = getState();
|
||||||
if (
|
if (
|
||||||
|
!trusted &&
|
||||||
!trustedLinks.domains?.includes(link.url.hostname)
|
!trustedLinks.domains?.includes(link.url.hostname)
|
||||||
) {
|
) {
|
||||||
openScreen({
|
openScreen({
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function ExternalLinkModal({ onClose, link }: Props) {
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openLink(link);
|
openLink(link, true);
|
||||||
onClose();
|
onClose();
|
||||||
},
|
},
|
||||||
confirmation: true,
|
confirmation: true,
|
||||||
|
|
Loading…
Reference in a new issue