2022-10-13 08:26:28 +00:00
|
|
|
import { IStateful } from '../base/app/types';
|
|
|
|
import { toState } from '../base/redux/functions';
|
2019-10-04 15:10:19 +00:00
|
|
|
|
|
|
|
const ETHERPAD_OPTIONS = {
|
|
|
|
showControls: 'true',
|
|
|
|
showChat: 'false',
|
|
|
|
showLineNumbers: 'true',
|
|
|
|
useMonospaceFont: 'false'
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the current sahred document URL.
|
|
|
|
*
|
|
|
|
* @param {Function|Object} stateful - The redux store or {@code getState} function.
|
|
|
|
* @returns {?string} - Current shared document URL or undefined.
|
|
|
|
*/
|
2022-10-13 08:26:28 +00:00
|
|
|
export function getSharedDocumentUrl(stateful: IStateful) {
|
2019-10-04 15:10:19 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const { documentUrl } = state['features/etherpad'];
|
|
|
|
const { displayName } = state['features/base/settings'];
|
|
|
|
|
|
|
|
if (!documentUrl) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
const params = new URLSearchParams(ETHERPAD_OPTIONS);
|
|
|
|
|
|
|
|
if (displayName) {
|
|
|
|
params.append('userName', displayName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return `${documentUrl}?${params.toString()}`;
|
|
|
|
}
|