diff --git a/src/App.tsx b/src/App.tsx index fe11e17..aedd578 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -16,6 +16,7 @@ limitations under the License. import React, { useState, useEffect } from 'react'; +import GlobalContext from './contexts/GlobalContext'; import SingleColumn from './layouts/SingleColumn'; import CreateLinkTile from './components/CreateLinkTile'; import MatrixTile from './components/MatrixTile'; @@ -24,8 +25,6 @@ import LinkRouter from './pages/LinkRouter'; import './App.scss'; -import GlobalContext from './contexts/GlobalContext'; - /* eslint-disable no-restricted-globals */ const App: React.FC = () => { diff --git a/src/components/HomeserverOptions.scss b/src/components/HomeserverOptions.scss index f0736c0..c4d0533 100644 --- a/src/components/HomeserverOptions.scss +++ b/src/components/HomeserverOptions.scss @@ -17,6 +17,16 @@ limitations under the License. @import '../color-scheme'; .homeserverOptions { + .actions { + display: flex; + width: 100%; + margin-top: 2em; + + > * { + flex: 1; + } + } + display: grid; row-gap: 20px; diff --git a/src/components/HomeserverOptions.tsx b/src/components/HomeserverOptions.tsx index 750b1c0..452a2e3 100644 --- a/src/components/HomeserverOptions.tsx +++ b/src/components/HomeserverOptions.tsx @@ -89,6 +89,14 @@ const HomeserverOptions: React.FC = ({ link }: IProps) => { return ( +
+ View this link using matrix.org to preview content, or you can + use another server or continue without a preview. +
+
+ Ask every time + +

diff --git a/src/pages/LinkRouter.tsx b/src/pages/LinkRouter.tsx index cf3b4d6..6bd0581 100644 --- a/src/pages/LinkRouter.tsx +++ b/src/pages/LinkRouter.tsx @@ -14,13 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -import React from 'react'; +import React, { useContext } from 'react'; +import HSContext, { HSOptions } from '../contexts/HSContext'; import Tile from '../components/Tile'; import LinkPreview from '../components/LinkPreview'; import InvitingClientTile from '../components/InvitingClientTile'; import { parseHash } from '../parser/parser'; import { LinkKind } from '../parser/types'; +import HomeserverOptions from '../components/HomeserverOptions'; /* eslint-disable no-restricted-globals */ @@ -31,42 +33,39 @@ interface IProps { const LinkRouter: React.FC = ({ link }: IProps) => { // our room id's will be stored in the hash const parsedLink = parseHash(link); + const [hsState] = useContext(HSContext); - let feedback: JSX.Element; - let client: JSX.Element = <>; - switch (parsedLink.kind) { - case LinkKind.ParseFailed: - feedback = ( - -

- That URL doesn't seem right. Links should be in the - format: -

-
-

- {location.host}/#/{'<'}matrix-resourceidentifier{'>'} -

-
- ); - break; - default: - if (parsedLink.arguments.client) { - client = ( - - ); - } - - feedback = ( - <> - - {client} - - ); + if (parsedLink.kind === LinkKind.ParseFailed) { + return ( + +

+ That URL doesn't seem right. Links should be in the format: +

+
+

+ {location.host}/#/{'<'}matrix-resourceidentifier{'>'} +

+
+ ); } - return feedback; + if (hsState.option === HSOptions.Unset) { + return ; + } + + let client: JSX.Element = <>; + if (parsedLink.arguments.client) { + client = ( + + ); + } + + return ( + <> + + {client} + + ); }; export default LinkRouter;