aboutsummaryrefslogtreecommitdiff
path: root/features/streamsGUI
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-03-27 15:41:20 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-03-27 15:41:20 +0800
commit0cf3a67c2bbd4cdaa5d364436c9153e6456624f1 (patch)
tree03d6b37ee2f4109875050d61d63f363659031e6b /features/streamsGUI
parentb94794a3de8827f4bddb5251b010dc32943d79a1 (diff)
downloadSoopyV2-0cf3a67c2bbd4cdaa5d364436c9153e6456624f1.tar.gz
SoopyV2-0cf3a67c2bbd4cdaa5d364436c9153e6456624f1.tar.bz2
SoopyV2-0cf3a67c2bbd4cdaa5d364436c9153e6456624f1.zip
make network requests all go on one permenantly open thread
Diffstat (limited to 'features/streamsGUI')
-rw-r--r--features/streamsGUI/index.js37
1 files changed, 18 insertions, 19 deletions
diff --git a/features/streamsGUI/index.js b/features/streamsGUI/index.js
index b9912c2..bc3fa6e 100644
--- a/features/streamsGUI/index.js
+++ b/features/streamsGUI/index.js
@@ -11,6 +11,7 @@ import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseCl
import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow";
import BoxWithText from "../../../guimanager/GuiElement/BoxWithText";
import { drawBoxAtBlock } from "../../utils/renderUtils";
+import { fetch } from "../../utils/networkUtils";
class StreamsGui extends Feature {
constructor() {
@@ -64,22 +65,22 @@ class StreamPage extends GuiPage {
}
updateStreams(){
- let streams = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/skyblockstreams"))
-
- this.streamsBox.clearChildren()
-
- let y = 0
-
- Object.keys(streams.twitch).forEach((channel, i)=>{
- let stream = streams.twitch[channel]
-
- if(i%2===0){
- this.streamsBox.addChild(new StreamElement().setStream(stream, true).setLocation(0, y, 0.45, 0.55).setStreamPage(this))
- }
- if(i%2===1){
- this.streamsBox.addChild(new StreamElement().setStream(stream, true).setLocation(0.55, y, 0.45, 0.55).setStreamPage(this))
- y+= 0.6
- }
+ fetch("http://soopymc.my.to/api/skyblockstreams").json(streams=>{
+ this.streamsBox.clearChildren()
+
+ let y = 0
+
+ Object.keys(streams.twitch).forEach((channel, i)=>{
+ let stream = streams.twitch[channel]
+
+ if(i%2===0){
+ this.streamsBox.addChild(new StreamElement().setStream(stream, true).setLocation(0, y, 0.45, 0.55).setStreamPage(this))
+ }
+ if(i%2===1){
+ this.streamsBox.addChild(new StreamElement().setStream(stream, true).setLocation(0.55, y, 0.45, 0.55).setStreamPage(this))
+ y+= 0.6
+ }
+ })
})
}
@@ -120,9 +121,7 @@ class StreamPage extends GuiPage {
}
onOpen(){
- new Thread(()=>{
- this.updateStreams()
- }).start()
+ this.updateStreams()
}
}