mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-12 01:52:49 +00:00
update soundlist on upload
This commit is contained in:
@@ -3,8 +3,6 @@ import axios from 'axios';
|
||||
|
||||
import './SoundList.scss';
|
||||
|
||||
let soundListCache;
|
||||
|
||||
export default class SoundList extends React.Component {
|
||||
|
||||
constructor() {
|
||||
@@ -19,10 +17,10 @@ export default class SoundList extends React.Component {
|
||||
}
|
||||
|
||||
getSoundList() {
|
||||
if (!soundListCache) {
|
||||
if (!this.soundListCache) {
|
||||
axios.get("/soundlist")
|
||||
.then((response) => {
|
||||
soundListCache = response.data;
|
||||
this.soundListCache = response.data;
|
||||
this.setState({
|
||||
soundList: response.data,
|
||||
});
|
||||
@@ -31,13 +29,12 @@ export default class SoundList extends React.Component {
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
soundList: soundListCache,
|
||||
soundList: this.soundListCache,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
checkExtension(extension) {
|
||||
console.log(extension);
|
||||
switch(extension) {
|
||||
case "wav":
|
||||
return true;
|
||||
|
||||
@@ -54,6 +54,10 @@ export default class Soundboard extends React.Component {
|
||||
uploaded: true,
|
||||
uploadError: " ",
|
||||
});
|
||||
|
||||
// reset sound list cache and load the new list
|
||||
this.refs.SoundList.soundListCache = undefined;
|
||||
this.refs.SoundList.getSoundList();
|
||||
}).catch((err) => {
|
||||
this.setState({
|
||||
percentCompleted: 0,
|
||||
@@ -73,7 +77,7 @@ export default class Soundboard extends React.Component {
|
||||
return (
|
||||
<div className="Soundboard">
|
||||
<div className="column">
|
||||
<SoundList/>
|
||||
<SoundList ref="SoundList"/>
|
||||
</div>
|
||||
|
||||
<div className="column">
|
||||
|
||||
Reference in New Issue
Block a user