Link to GtS settings when we know we are on GtS
This commit is contained in:
parent
0e4dd6ee39
commit
bc0f856d72
|
@ -173,5 +173,6 @@ export const ICONS = {
|
||||||
settings: () => import('@iconify-icons/mingcute/settings-6-line'),
|
settings: () => import('@iconify-icons/mingcute/settings-6-line'),
|
||||||
'heart-break': () => import('@iconify-icons/mingcute/heart-crack-line'),
|
'heart-break': () => import('@iconify-icons/mingcute/heart-crack-line'),
|
||||||
'user-x': () => import('@iconify-icons/mingcute/user-x-line'),
|
'user-x': () => import('@iconify-icons/mingcute/user-x-line'),
|
||||||
|
'user-setting': () => import('@iconify-icons/mingcute/user-setting-line'),
|
||||||
minimize: () => import('@iconify-icons/mingcute/arrows-down-line'),
|
minimize: () => import('@iconify-icons/mingcute/arrows-down-line'),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import './nav-menu.css';
|
import './nav-menu.css';
|
||||||
|
|
||||||
import { ControlledMenu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
import { ControlledMenu, FocusableItem, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||||
import { memo } from 'preact/compat';
|
import { memo } from 'preact/compat';
|
||||||
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
||||||
import { useLongPress } from 'use-long-press';
|
import { useLongPress } from 'use-long-press';
|
||||||
|
@ -18,6 +18,7 @@ import Avatar from './avatar';
|
||||||
import Icon from './icon';
|
import Icon from './icon';
|
||||||
import MenuLink from './menu-link';
|
import MenuLink from './menu-link';
|
||||||
import SubMenu2 from './submenu2';
|
import SubMenu2 from './submenu2';
|
||||||
|
import { accountsIsDtth, gtsDtthSettings } from '../utils/dtth';
|
||||||
|
|
||||||
function NavMenu(props) {
|
function NavMenu(props) {
|
||||||
const snapStates = useSnapshot(states);
|
const snapStates = useSnapshot(states);
|
||||||
|
@ -209,6 +210,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) &&
|
||||||
|
<FocusableItem title="Takes you to DTTHDon settings">
|
||||||
|
<a href={gtsDtthSettings} target='_blank'><Icon icon="user-setting" size="l" /> <span>User Settings…</span></a>
|
||||||
|
</FocusableItem>}
|
||||||
{lists?.length > 0 ? (
|
{lists?.length > 0 ? (
|
||||||
<SubMenu2
|
<SubMenu2
|
||||||
menuClassName="nav-submenu"
|
menuClassName="nav-submenu"
|
||||||
|
|
|
@ -12,6 +12,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;
|
||||||
|
|
||||||
|
@ -24,7 +25,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
13
src/utils/dtth.js
Normal 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';
|
Loading…
Reference in a new issue