Make instances optional

This commit is contained in:
Lim Chee Aun 2023-04-14 11:13:14 +08:00
parent 4f577321b2
commit 650af38a28
2 changed files with 13 additions and 3 deletions

View file

@ -60,7 +60,8 @@ const TYPE_PARAMS = {
text: 'Instance',
name: 'instance',
type: 'text',
placeholder: 'e.g. mastodon.social',
placeholder: 'Optional, e.g. mastodon.social',
notRequired: true,
},
],
trending: [
@ -68,7 +69,8 @@ const TYPE_PARAMS = {
text: 'Instance',
name: 'instance',
type: 'text',
placeholder: 'e.g. mastodon.social',
placeholder: 'Optional, e.g. mastodon.social',
notRequired: true,
},
],
search: [

View file

@ -7,6 +7,7 @@ import { useNavigate } from 'react-router-dom';
import { useSnapshot } from 'valtio';
import { SHORTCUTS_META } from '../components/shortcuts-settings';
import { api } from '../utils/api';
import states from '../utils/states';
import AsyncText from './AsyncText';
@ -15,6 +16,7 @@ import Link from './link';
import MenuLink from './menu-link';
function Shortcuts() {
const { instance } = api();
const snapStates = useSnapshot(states);
const { shortcuts } = snapStates;
@ -36,7 +38,13 @@ function Shortcuts() {
id = id(data, i);
}
if (typeof path === 'function') {
path = path(data, i);
path = path(
{
...data,
instance: data.instance || instance,
},
i,
);
}
if (typeof title === 'function') {
title = title(data, i);