Skip to content

Commit

Permalink
Fetch settings json directly without api (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
chunweii authored Oct 12, 2023
1 parent f07a240 commit f5c7fed
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/core/services/github.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const { Octokit } = require('@octokit/rest');
const CATCHER_ORG = 'CATcher-org';
const CATCHER_REPO = 'CATcher';
const UNABLE_TO_OPEN_IN_BROWSER = 'Unable to open this issue in Browser';
function getSettingsUrl(org: string, repoName: string): string {
return `https://raw.githubusercontent.com/${org}/${repoName}/master/settings.json`;
}

let ORG_NAME = '';
let MOD_ORG = '';
Expand Down Expand Up @@ -398,10 +401,8 @@ export class GithubService {
* @return Observable<SessionData> representing session information.
*/
fetchSettingsFile(): Observable<SessionData> {
return from(
octokit.repos.getContents({ owner: MOD_ORG, repo: DATA_REPO, path: 'settings.json', headers: GithubService.IF_NONE_MATCH_EMPTY })
).pipe(
map((rawData) => JSON.parse(atob(rawData['data']['content']))),
return from(fetch(getSettingsUrl(MOD_ORG, DATA_REPO))).pipe(
mergeMap((res) => res.json()),
catchError((err) => throwError('Failed to fetch settings file.'))
);
}
Expand Down

0 comments on commit f5c7fed

Please sign in to comment.