fix: pass username and instance url to external actions. Fixes #3130
This commit is contained in:
parent
5876c7cfbb
commit
00a5fb8dc8
@ -123,6 +123,7 @@ export const Content: FC = () => {
|
|||||||
const { enabled: browserNotificationsEnabled } = browserNotifications;
|
const { enabled: browserNotificationsEnabled } = browserNotifications;
|
||||||
const { online: isStreamLive } = serverStatus;
|
const { online: isStreamLive } = serverStatus;
|
||||||
const [externalActionToDisplay, setExternalActionToDisplay] = useState<ExternalAction>(null);
|
const [externalActionToDisplay, setExternalActionToDisplay] = useState<ExternalAction>(null);
|
||||||
|
const [currentBrowserWindowUrl, setCurrentBrowserWindowUrl] = useState('');
|
||||||
|
|
||||||
const [supportsBrowserNotifications, setSupportsBrowserNotifications] = useState(false);
|
const [supportsBrowserNotifications, setSupportsBrowserNotifications] = useState(false);
|
||||||
const supportFediverseFeatures = fediverseEnabled;
|
const supportFediverseFeatures = fediverseEnabled;
|
||||||
@ -131,11 +132,24 @@ export const Content: FC = () => {
|
|||||||
|
|
||||||
const externalActionSelected = (action: ExternalAction) => {
|
const externalActionSelected = (action: ExternalAction) => {
|
||||||
const { openExternally, url } = action;
|
const { openExternally, url } = action;
|
||||||
|
const { displayName } = currentUser;
|
||||||
|
|
||||||
|
const updatedUrl = new URL(url);
|
||||||
|
// Append url and username to params so the link knows where we came from and who we are.
|
||||||
|
updatedUrl.searchParams.append('username', displayName);
|
||||||
|
updatedUrl.searchParams.append('instance', currentBrowserWindowUrl);
|
||||||
|
const fullUrl = updatedUrl.toString();
|
||||||
|
// Overwrite URL with the updated one that includes the params.
|
||||||
|
const updatedAction = {
|
||||||
|
...action,
|
||||||
|
url: fullUrl,
|
||||||
|
};
|
||||||
|
|
||||||
// apply openExternally only if we don't have an HTML embed
|
// apply openExternally only if we don't have an HTML embed
|
||||||
if (openExternally && url) {
|
if (openExternally && updatedAction) {
|
||||||
window.open(url, '_blank');
|
window.open(fullUrl, '_blank');
|
||||||
} else {
|
} else {
|
||||||
setExternalActionToDisplay(action);
|
setExternalActionToDisplay(updatedAction);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -185,6 +199,10 @@ export const Content: FC = () => {
|
|||||||
);
|
);
|
||||||
}, [browserNotificationsEnabled]);
|
}, [browserNotificationsEnabled]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCurrentBrowserWindowUrl(window.location.href);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const showChat = isChatAvailable && !chatDisabled && chatState === ChatState.VISIBLE;
|
const showChat = isChatAvailable && !chatDisabled && chatState === ChatState.VISIBLE;
|
||||||
|
|
||||||
// accounts for sidebar width when online in desktop
|
// accounts for sidebar width when online in desktop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user