[MM-22555] Auto-fill server URLs when deep linking into the Desktop App and the server isn't configured (#3200)

* Allow deep linking to non-configured servers by auto filling the modal

* Fall back to base URL if URL with path name does not work

* Allow deep linking directly into a new server with a permalink

* Support welcome screen/no server case

* Some cleanup
This commit is contained in:
Devin Binnie
2024-11-18 14:08:00 -05:00
committed by GitHub
parent 21487e2496
commit 8aa0b86c7a
14 changed files with 107 additions and 38 deletions

View File

@@ -20,6 +20,7 @@ import 'renderer/css/components/LoadingScreen.css';
type ConfigureServerProps = {
server?: UniqueServer;
prefillURL?: string;
mobileView?: boolean;
darkMode?: boolean;
messageTitle?: string;
@@ -33,6 +34,7 @@ type ConfigureServerProps = {
function ConfigureServer({
server,
prefillURL,
mobileView,
darkMode,
messageTitle,
@@ -53,8 +55,8 @@ function ConfigureServer({
const mounted = useRef(false);
const [transition, setTransition] = useState<'inFromRight' | 'outToLeft'>();
const [name, setName] = useState(prevName || '');
const [url, setUrl] = useState(prevURL || '');
const [name, setName] = useState(prevName ?? '');
const [url, setUrl] = useState(prevURL ?? prefillURL ?? '');
const [nameError, setNameError] = useState('');
const [urlError, setURLError] = useState<{type: STATUS; value: string}>();
const [showContent, setShowContent] = useState(false);
@@ -71,6 +73,11 @@ function ConfigureServer({
setTransition('inFromRight');
setShowContent(true);
mounted.current = true;
if (url) {
fetchValidationResult(url);
}
return () => {
mounted.current = false;
};

View File

@@ -27,6 +27,7 @@ type Props = {
currentOrder?: number;
setInputRef?: (inputRef: HTMLInputElement) => void;
intl: IntlShape;
prefillURL?: string;
};
type State = {
@@ -77,6 +78,13 @@ class NewServerModal extends React.PureComponent<Props, State> {
this.mounted = false;
}
componentDidUpdate(prevProps: Readonly<Props>): void {
if (this.props.prefillURL && this.props.prefillURL !== prevProps.prefillURL) {
this.setState({serverUrl: this.props.prefillURL});
this.validateServerURL(this.props.prefillURL);
}
}
initializeOnShow = async () => {
const cameraDisabled = window.process.platform === 'win32' && await window.desktop.getMediaAccessStatus('camera') !== 'granted';
const microphoneDisabled = window.process.platform === 'win32' && await window.desktop.getMediaAccessStatus('microphone') !== 'granted';