In-App Links in Channel's Bookmarks (#3454)

* Enhance mattermost:// protocol handling for in-app links

- Add isMattermostProtocol() helper function to identify mattermost:// URLs
- Update webContentEvents to handle mattermost:// links through internal deep linking
- Ensure mattermost:// links in bookmarks open within the app instead of external dialog
- Maintain existing custom protocol dialog for other non-http/https protocols

This improves the user experience by allowing mattermost:// bookmarks to navigate
directly within the desktop app without prompting external application dialogs.

* Fix trailing spaces linting error

---------

Co-authored-by: Dmitry Spasskiy <dmitry.spassky@raiffeisen.ru>
This commit is contained in:
thatguy
2025-07-08 22:23:59 +03:00
committed by GitHub
parent 4cffce3cdb
commit 7c9f6ff32c
2 changed files with 13 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ import ViewManager from 'main/views/viewManager';
import CallsWidgetWindow from 'main/windows/callsWidgetWindow'; import CallsWidgetWindow from 'main/windows/callsWidgetWindow';
import MainWindow from 'main/windows/mainWindow'; import MainWindow from 'main/windows/mainWindow';
import {generateHandleConsoleMessage, isCustomProtocol} from './webContentEventsCommon'; import {generateHandleConsoleMessage, isCustomProtocol, isMattermostProtocol} from './webContentEventsCommon';
import allowProtocolDialog from '../allowProtocolDialog'; import allowProtocolDialog from '../allowProtocolDialog';
import {composeUserAgent} from '../utils'; import {composeUserAgent} from '../utils';
@@ -131,7 +131,13 @@ export class WebContentsEventManager {
return PluginsPopUpsManager.handleNewWindow(webContentsId, details); return PluginsPopUpsManager.handleNewWindow(webContentsId, details);
} }
// Check for custom protocol // Check for mattermost protocol - handle internally
if (isMattermostProtocol(parsedURL)) {
ViewManager.handleDeepLink(parsedURL);
return {action: 'deny'};
}
// Check for other custom protocols
if (isCustomProtocol(parsedURL)) { if (isCustomProtocol(parsedURL)) {
allowProtocolDialog.handleDialogEvent(parsedURL.protocol, details.url); allowProtocolDialog.handleDialogEvent(parsedURL.protocol, details.url);
return {action: 'deny'}; return {action: 'deny'};

View File

@@ -34,3 +34,8 @@ export function isCustomProtocol(url: URL) {
const scheme = protocols && protocols[0] && protocols[0].schemes && protocols[0].schemes[0]; const scheme = protocols && protocols[0] && protocols[0].schemes && protocols[0].schemes[0];
return url.protocol !== 'http:' && url.protocol !== 'https:' && url.protocol !== `${scheme}:`; return url.protocol !== 'http:' && url.protocol !== 'https:' && url.protocol !== `${scheme}:`;
} }
export function isMattermostProtocol(url: URL) {
const scheme = protocols && protocols[0] && protocols[0].schemes && protocols[0].schemes[0];
return url.protocol === `${scheme}:`;
}