mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
feat: always show link warning for masked links
This commit is contained in:
2
external/lang
vendored
2
external/lang
vendored
Submodule external/lang updated: 4cfba33bf5...42a8856899
@@ -142,7 +142,11 @@ export default function Embed({ embed }: Props) {
|
|||||||
<a
|
<a
|
||||||
onMouseDown={(ev) =>
|
onMouseDown={(ev) =>
|
||||||
(ev.button === 0 || ev.button === 1) &&
|
(ev.button === 0 || ev.button === 1) &&
|
||||||
modalController.openLink(embed.url!)
|
modalController.openLink(
|
||||||
|
embed.url!,
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
className={styles.title}>
|
className={styles.title}>
|
||||||
{embed.title}
|
{embed.title}
|
||||||
@@ -194,7 +198,8 @@ export default function Embed({ embed }: Props) {
|
|||||||
modalController.push({ type: "image_viewer", embed })
|
modalController.push({ type: "image_viewer", embed })
|
||||||
}
|
}
|
||||||
onMouseDown={(ev) =>
|
onMouseDown={(ev) =>
|
||||||
ev.button === 1 && modalController.openLink(embed.url)
|
ev.button === 1 &&
|
||||||
|
modalController.openLink(embed.url, undefined, true)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ export function RenderAnchor({
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
onClick={(ev) =>
|
onClick={(ev) =>
|
||||||
modalController.openLink(href) && ev.preventDefault()
|
modalController.openLink(
|
||||||
|
href,
|
||||||
|
undefined,
|
||||||
|
ev.currentTarget.innerText !== href,
|
||||||
|
) && ev.preventDefault()
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -208,12 +208,25 @@ class ModalControllerExtended extends ModalController<Modal> {
|
|||||||
* Safely open external or internal link
|
* Safely open external or internal link
|
||||||
* @param href Raw URL
|
* @param href Raw URL
|
||||||
* @param trusted Whether we trust this link
|
* @param trusted Whether we trust this link
|
||||||
|
* @param mismatch Whether to always open link warning
|
||||||
* @returns Whether to cancel default event
|
* @returns Whether to cancel default event
|
||||||
*/
|
*/
|
||||||
openLink(href?: string, trusted?: boolean) {
|
openLink(href?: string, trusted?: boolean, mismatch?: boolean) {
|
||||||
const link = determineLink(href);
|
const link = determineLink(href);
|
||||||
const settings = getApplicationState().settings;
|
const settings = getApplicationState().settings;
|
||||||
|
|
||||||
|
if (mismatch) {
|
||||||
|
if (href) {
|
||||||
|
modalController.push({
|
||||||
|
type: "link_warning",
|
||||||
|
link: href,
|
||||||
|
callback: () => this.openLink(href, true) as true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (link.type) {
|
switch (link.type) {
|
||||||
case "navigate": {
|
case "navigate": {
|
||||||
history.push(link.path);
|
history.push(link.path);
|
||||||
|
|||||||
Reference in New Issue
Block a user