Link to GtS settings when we know we are on GtS

This commit is contained in:
Natsu Kagami 2023-07-17 12:30:17 +02:00
parent b8d0ffce17
commit 251cc8a4cf
Signed by: nki
GPG key ID: 55A032EB38B49ADB
4 changed files with 21 additions and 1 deletions

View file

@ -103,4 +103,5 @@ export const ICONS = {
'arrows-right': () => import('@iconify-icons/mingcute/arrows-right-line'), 'arrows-right': () => import('@iconify-icons/mingcute/arrows-right-line'),
code: () => import('@iconify-icons/mingcute/code-line'), code: () => import('@iconify-icons/mingcute/code-line'),
copy: () => import('@iconify-icons/mingcute/copy-2-line'), copy: () => import('@iconify-icons/mingcute/copy-2-line'),
'user-setting': () => import('@iconify-icons/mingcute/user-setting-line'),
}; };

View file

@ -19,6 +19,7 @@ import store from '../utils/store';
import Avatar from './avatar'; import Avatar from './avatar';
import Icon from './icon'; import Icon from './icon';
import MenuLink from './menu-link'; import MenuLink from './menu-link';
import { accountsIsDtth, gtsDtthSettings } from '../utils/dtth';
function NavMenu(props) { function NavMenu(props) {
const snapStates = useSnapshot(states); const snapStates = useSnapshot(states);
@ -203,6 +204,10 @@ function NavMenu(props) {
<Icon icon="user" size="l" /> <span>Profile</span> <Icon icon="user" size="l" /> <span>Profile</span>
</MenuLink> </MenuLink>
)} )}
{currentAccount && accountsIsDtth(currentAccount) &&
<MenuLink to={gtsDtthSettings} target='_blank' title="Takes you to DTTHDon settings">
<Icon icon="user-setting" size="l" /> <span>User Settings&hellip;</span>
</MenuLink>}
<MenuLink to="/l"> <MenuLink to="/l">
<Icon icon="list" size="l" /> <span>Lists</span> <Icon icon="list" size="l" /> <span>Lists</span>
</MenuLink> </MenuLink>

View file

@ -11,6 +11,7 @@ import instancesListURL from '../data/instances.json?url';
import { getAuthorizationURL, registerApplication } from '../utils/auth'; import { getAuthorizationURL, registerApplication } from '../utils/auth';
import store from '../utils/store'; import store from '../utils/store';
import useTitle from '../utils/useTitle'; import useTitle from '../utils/useTitle';
import { gtsDtth } from '../utils/dtth';
const { PHANPY_DEFAULT_INSTANCE: DEFAULT_INSTANCE } = import.meta.env; const { PHANPY_DEFAULT_INSTANCE: DEFAULT_INSTANCE } = import.meta.env;
@ -23,7 +24,7 @@ function Login() {
const instance = searchParams.get('instance'); const instance = searchParams.get('instance');
const submit = searchParams.get('submit'); const submit = searchParams.get('submit');
const [instanceText, setInstanceText] = useState( const [instanceText, setInstanceText] = useState(
instance || cachedInstanceURL?.toLowerCase() || 'gts.dtth.ch', instance || cachedInstanceURL?.toLowerCase() || gtsDtth,
); );
const [instancesList, setInstancesList] = useState([]); const [instancesList, setInstancesList] = useState([]);

13
src/utils/dtth.js Normal file
View file

@ -0,0 +1,13 @@
export function accountsIsDtth(account) {
return (
account.info &&
typeof account.info.url === 'string' &&
account.info.url.startsWith(gtsDtth)
);
}
/** URL to DTTHDon */
export const gtsDtth = 'https://gts.dtth.ch';
/** URL to DTTHDon settings */
export const gtsDtthSettings = 'https://gts.dtth.ch/settings';