Skip to content
This repository has been archived by the owner on Jun 6, 2022. It is now read-only.

Commit

Permalink
Don't force importers to use API
Browse files Browse the repository at this point in the history
  • Loading branch information
doZennn committed Sep 9, 2019
1 parent 37bd565 commit 27701bd
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/js/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TopBlur from './TopBlur';
import queryString from 'query-string';
import PropTypes from 'prop-types';
import PubSub from 'pubsub-js';
import {officialList} from './importers';
const SGDB = window.require('steamgriddb');
const Store = window.require('electron-store');

Expand Down Expand Up @@ -89,7 +90,7 @@ class Search extends React.Component {
});
}

if (this.gameType === 'shortcut' && this.platform !== 'other') {
if (this.gameType === 'shortcut' && officialList.includes(this.platform)) {
client.getGrids({id: this.gameId, type: this.platform})
.then((items) => {
this.setState({
Expand All @@ -102,9 +103,7 @@ class Search extends React.Component {
apiError: true
});
});
}

if (this.gameType === 'shortcut' && this.platform === 'other') {
} else if (this.gameType === 'shortcut' && !officialList.includes(this.platform)) {
client.searchGame(this.query)
.then((res) => {
client.getGridsById(res[0].id)
Expand Down
15 changes: 14 additions & 1 deletion src/js/importers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@ const importAll = (r) => r.keys().forEach((key) => importers[key] = r(key));
const context = require.context('./importers/', false, /\.js$/);
importAll(context);

export default importers;
export default importers;

function getOfficial() {
const officialList = [];
Object.keys(importers).forEach((module) => {
if (importers[module].official) {
officialList.push(importers[module].id);
}
});
return officialList;
}

// Array of imprter ids
export const officialList = getOfficial();
3 changes: 2 additions & 1 deletion src/js/importers/BattleNet.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ class BattleNet {

export default BattleNet;
export const name = 'Blizzard Battle.net';
export const id = 'bnet';
export const id = 'bnet';
export const official = true;
3 changes: 2 additions & 1 deletion src/js/importers/Epic.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ class Epic {

export default Epic;
export const name = 'Epic Games Launcher';
export const id = 'egs';
export const id = 'egs';
export const official = true;
3 changes: 2 additions & 1 deletion src/js/importers/Gog.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ class Gog {

export default Gog;
export const name = 'GOG.com';
export const id = 'gog';
export const id = 'gog';
export const official = true;
3 changes: 2 additions & 1 deletion src/js/importers/Origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,5 @@ class Origin {

export default Origin;
export const name = 'Origin';
export const id = 'origin';
export const id = 'origin';
export const official = true;
3 changes: 2 additions & 1 deletion src/js/importers/Uplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,5 @@ class Uplay {

export default Uplay;
export const name = 'Uplay';
export const id = 'uplay';
export const id = 'uplay';
export const official = true;

0 comments on commit 27701bd

Please sign in to comment.