Skip to content

Commit

Permalink
Merge pull request #2034 from candela97/fix-itad-sync-notes-error
Browse files Browse the repository at this point in the history
Fix error when pulled notes are empty
  • Loading branch information
tfedor authored Sep 15, 2024
2 parents 1b1ca7c + aa59209 commit a9601f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/js/Background/Modules/IsThereAnyDeal/ITADApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ export default class ITADApi extends Api implements MessageHandlerInterface {
throw new Errors.OAuthUnauthorized();
}

const result: TNotesList = [];

const response = await this.fetchJson<TGetNotesApiResponse>(
this.getUrl("/user/notes/v1"), {
method: "GET",
Expand All @@ -422,13 +424,16 @@ export default class ITADApi extends Api implements MessageHandlerInterface {
}
});

if (response.length === 0) {
return result;
}

const notes: Map<string, string> = new Map<string, string>(
response.map(o => [o.gid, o.note])
);

const steamIds = await this.fetchSteamIds([...notes.keys()]);

const result: TNotesList = [];
for (let [steamId, gid] of steamIds) {
if (!steamId.startsWith("app/")) {
continue;
Expand Down

0 comments on commit a9601f4

Please sign in to comment.