Skip to content

Commit

Permalink
fixed: exception fetching own collection list if logged out
Browse files Browse the repository at this point in the history
unreleased of course
  • Loading branch information
TanninOne committed Sep 8, 2022
1 parent 6e46855 commit 874f706
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/extensions/nexus_integration/eventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,18 @@ export function onNexusDownload(api: IExtensionApi,
export function onGetMyCollections(api: IExtensionApi, nexus: Nexus)
: (gameId: string, count?: number, offset?: number) => Promise<IRevision[]> {
return (gameId: string, count?: number, offset?: number): Promise<IRevision[]> => {
if (api.getState().persistent['nexus']?.userInfo?.userId === undefined) {
return Promise.resolve([]);
}
const game = gameById(api.getState(), gameId);
return Promise.resolve(nexus.getMyCollections(
CURRENT_REVISION_INFO, nexusGameId(game), count, offset))
.then(res => res.map(coll => coll.currentRevision))
.then(res => (res ?? []).map(coll => coll.currentRevision))
.catch(err => {
api.showErrorNotification('Failed to get list of collections', err);
return Promise.resolve(undefined);
if (err.code !== 'UNAUTHORIZED') {
api.showErrorNotification('Failed to get list of collections', err);
}
return Promise.resolve([]);
});
};
}
Expand Down

0 comments on commit 874f706

Please sign in to comment.