Public Access
Feed links go to the game and to the profile view of that game. Add /following page, nav item and an opt-in Following tile. Games not in your library show a catalog view with an add button.
This commit is contained in:
1 parent
720764bf68
commit
5be0d42bca
31 files changed
+692
-67
No files matched your search
@@ -22,11 +22,14 @@ import {useCurrentUserContext} from '../context/CurrentUserContext.jsx';
|
||||
/**
|
||||
* Search IGDB and add a game the user owns outside Steam, e.g. on PlayStation or Switch; or check several and review
|
||||
* them on the import page.
|
||||
*
|
||||
* @param onAdded called with the new appid before the navigation, for a page that shows the same address
|
||||
* @param initialQuery the search text to start with, e.g. the name of a game seen elsewhere
|
||||
*/
|
||||
export default function AddGamePanel({onClose}) {
|
||||
export default function AddGamePanel({onClose, onAdded, initialQuery = ''}) {
|
||||
const {t} = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [query, setQuery] = useState('');
|
||||
const [query, setQuery] = useState(initialQuery);
|
||||
const [picked, setPicked] = useState(null);
|
||||
// igdbId -> hit, over several searches.
|
||||
const [selected, setSelected] = useState(() => new Map());
|
||||
@@ -62,7 +65,8 @@ export default function AddGamePanel({onClose}) {
|
||||
</div>
|
||||
|
||||
{picked ? (
|
||||
<AddForm hit={picked} favorite={favorite} onBack={() => setPicked(null)} navigate={navigate}/>
|
||||
<AddForm hit={picked} favorite={favorite} onBack={() => setPicked(null)} navigate={navigate}
|
||||
onAdded={onAdded}/>
|
||||
) : (
|
||||
<>
|
||||
<p className="text-sm text-muted-foreground">{t('MANUAL_GAME.ADD_HINT')}</p>
|
||||
@@ -82,7 +86,7 @@ export default function AddGamePanel({onClose}) {
|
||||
);
|
||||
}
|
||||
|
||||
function AddForm({hit, favorite, onBack, navigate}) {
|
||||
function AddForm({hit, favorite, onBack, navigate, onAdded}) {
|
||||
const {t} = useTranslation();
|
||||
const [platform, setPlatform] = useState(() => preselectPlatform(null, hit.platforms, favorite));
|
||||
// The favorite can arrive after the pick; it fills only a platform the user has not picked yet.
|
||||
@@ -113,6 +117,7 @@ function AddForm({hit, favorite, onBack, navigate}) {
|
||||
const {appid} = await response.json();
|
||||
toast.success(t('MANUAL_GAME.ADDED', {name: hit.name}));
|
||||
check(appid, {status, tell: true});
|
||||
onAdded?.(appid);
|
||||
navigate(`/library/${appid}`);
|
||||
} catch (err) {
|
||||
console.error('add game error:', err);
|
||||
|
||||
Reference in new issue
Block a user