mirror of
https://github.com/owncast/owncast.git
synced 2024-11-21 20:28:15 +03:00
fix: pass username and instance url to external actions. Fixes #3130
This commit is contained in:
parent
5876c7cfbb
commit
00a5fb8dc8
1 changed files with 21 additions and 3 deletions
|
@ -123,6 +123,7 @@ export const Content: FC = () => {
|
|||
const { enabled: browserNotificationsEnabled } = browserNotifications;
|
||||
const { online: isStreamLive } = serverStatus;
|
||||
const [externalActionToDisplay, setExternalActionToDisplay] = useState<ExternalAction>(null);
|
||||
const [currentBrowserWindowUrl, setCurrentBrowserWindowUrl] = useState('');
|
||||
|
||||
const [supportsBrowserNotifications, setSupportsBrowserNotifications] = useState(false);
|
||||
const supportFediverseFeatures = fediverseEnabled;
|
||||
|
@ -131,11 +132,24 @@ export const Content: FC = () => {
|
|||
|
||||
const externalActionSelected = (action: ExternalAction) => {
|
||||
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
|
||||
if (openExternally && url) {
|
||||
window.open(url, '_blank');
|
||||
if (openExternally && updatedAction) {
|
||||
window.open(fullUrl, '_blank');
|
||||
} else {
|
||||
setExternalActionToDisplay(action);
|
||||
setExternalActionToDisplay(updatedAction);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -185,6 +199,10 @@ export const Content: FC = () => {
|
|||
);
|
||||
}, [browserNotificationsEnabled]);
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentBrowserWindowUrl(window.location.href);
|
||||
}, []);
|
||||
|
||||
const showChat = isChatAvailable && !chatDisabled && chatState === ChatState.VISIBLE;
|
||||
|
||||
// accounts for sidebar width when online in desktop
|
||||
|
|
Loading…
Reference in a new issue