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 ee7d5e3049
commit cf933ad379
Signed by: nki
GPG key ID: 55A032EB38B49ADB
4 changed files with 22 additions and 1 deletions

View file

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

View file

@ -5,6 +5,7 @@ import {
MenuDivider,
MenuItem,
SubMenu,
FocusableItem,
} from '@szhsin/react-menu';
import { memo } from 'preact/compat';
import { useEffect, useRef, useState } from 'preact/hooks';
@ -19,6 +20,7 @@ import store from '../utils/store';
import Avatar from './avatar';
import Icon from './icon';
import MenuLink from './menu-link';
import { accountsIsDtth, gtsDtthSettings } from '../utils/dtth';
function NavMenu(props) {
const snapStates = useSnapshot(states);
@ -203,6 +205,10 @@ function NavMenu(props) {
<Icon icon="user" size="l" /> <span>Profile</span>
</MenuLink>
)}
{currentAccount && accountsIsDtth(currentAccount) &&
<FocusableItem title="Takes you to DTTHDon settings">
<a href={gtsDtthSettings} target='_blank'><Icon icon="user-setting" size="l" /> <span>User Settings&hellip;</span></a>
</FocusableItem>}
<MenuLink to="/l">
<Icon icon="list" size="l" /> <span>Lists</span>
</MenuLink>

View file

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