Skip to content

Commit

Permalink
fix(Bot): fixed crashes + env api key v1 (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gumatan authored Mar 13, 2022
1 parent 2f9f164 commit c4c6e1b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/Bot.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
### Requirement

- Your Osu! IRC credentials user and password these are not the same as your Osu! account credentials (Get them at https://osu.ppy.sh/p/irc)
- An Osu! API key, it will be used to fetch infos about beatmaps and matchs (Get it at https://osu.ppy.sh/p/api)
- A Osu! API key V1 (V2 api is not compatible), it will be used to fetch infos about beatmaps and matchs (Get it at https://osu.ppy.sh/p/api)

### Setup process

Expand Down
2 changes: 1 addition & 1 deletion src/App/modules/Settings/helpers/baseConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default Object.freeze({
isBotAccount: false,
},
osuApi: {
key: '',
key: process.env.API_KEY_V1,
},
},
beatconnectAPI: {
Expand Down
3 changes: 2 additions & 1 deletion src/App/modules/common/Beatmap/Cover.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const Cover = ({ url, width, height, paddingBottom, roundedTop, noFade, canLoad
};
return (
<div className="cover" style={style}>
<BeatmapDetails beatmapSet={beatmapSet} cardRef={parentRef} />
{beatmapSet && parentRef && beatmapSet.beatmaps &&
<BeatmapDetails beatmapSet={beatmapSet} cardRef={parentRef} />}
</div>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/App/modules/common/Beatmap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const Beatmap = ({ beatmap, noFade, autoDl, width, ...otherProps }) => {
const theme = useTheme();
const [isPlaying, setIsPLaying] = useState(false);
const { beatmapset_id, id, title, artist, creator, version, bpm, beatconnectDlLink, beatmaps } = beatmap;
const wallpaperBeatmapId = beatmaps[Math.max(beatmaps.length - 2, 0)].id;
// beatmap.beatmap_id only when beatmap comes from mpMatch (for bot displays)
const wallpaperBeatmapId = beatmaps ? beatmaps[Math.max(beatmaps.length - 2, 0)].id : beatmap.beatmap_id;

const classes = useStyles({ width, theme, isPlaying, bpm: beatmap.bpm, ...otherProps });
return (
Expand Down
6 changes: 3 additions & 3 deletions src/Bot/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const updateMatchsList = newMatchs => {
trackEvent('bot', 'matchs', 'connectedMatchsCount', newMatchs.length || 0);
};
export const updateSingleMatch = matchUpdate => {
const newMatchs = store.getState().bot.mpMatchs.map(match => (match.id === matchUpdate.id ? matchUpdate : match));
store.dispatch({ type: 'UPDATE_SINGLE_MATCH', newMatchs });
trackEvent('bot', 'matchs', 'connectedMatchsCount', newMatchs.length || 0);
const matchCount = store.getState().bot.mpMatchs.length
store.dispatch({ type: 'UPDATE_SINGLE_MATCH', newMatch:matchUpdate });
trackEvent('bot', 'matchs', 'connectedMatchsCount', matchCount || 0);
};
2 changes: 1 addition & 1 deletion src/Bot/msg/mpSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import store from '../../shared/store';
import { updateSingleMatch } from '../actions';

export default function(msg) {
const osuApi = store.getState().main.bot.osuApi;
const osuApi = store.getState().bot.instance.osuApi;

let msgDatas = msg.split(',').map(data => data.split(/:(?!\/)/g));
//msgDatas = msgDatas
Expand Down
2 changes: 2 additions & 0 deletions src/mirage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export function makeServer() {

return mock;
});

this.passthrough('https://osu.ppy.sh/api/**');
},
});
}

0 comments on commit c4c6e1b

Please sign in to comment.