Spaces:
Running
Running
Commit
•
1f5297a
1
Parent(s):
4efa5d3
fix code computing audience
Browse files- public/index.html +10 -5
public/index.html
CHANGED
@@ -142,17 +142,21 @@ function app() {
|
|
142 |
const res = await fetch('/stats')
|
143 |
audience = await res.json()
|
144 |
} catch (err) {
|
145 |
-
|
146 |
}
|
147 |
-
|
148 |
-
|
149 |
-
this.channels = Object.entries(this.channels).reduce((acc, [channel, data]) => ({
|
|
|
|
|
|
|
150 |
...acc,
|
151 |
[channel]: {
|
152 |
...data,
|
153 |
audience: audience[channel] || 0
|
154 |
}
|
155 |
-
}))
|
|
|
156 |
},
|
157 |
fullscreen() {
|
158 |
if (this.video.requestFullscreen) {
|
@@ -204,6 +208,7 @@ function app() {
|
|
204 |
document.addEventListener("click", handleActivity)
|
205 |
document.addEventListener("mousemove", handleActivity)
|
206 |
|
|
|
207 |
setInterval(() => {
|
208 |
this.checkAudience()
|
209 |
}, 2000)
|
|
|
142 |
const res = await fetch('/stats')
|
143 |
audience = await res.json()
|
144 |
} catch (err) {
|
145 |
+
console.log('failed to check the audience, something is wrong')
|
146 |
}
|
147 |
+
|
148 |
+
window.DEBUGME = Object.entries(this.channels)
|
149 |
+
this.channels = Object.entries(this.channels).reduce((acc, [channel, data]) => ((console.log('debug:', {
|
150 |
+
...data,
|
151 |
+
audience: audience[channel] || 0
|
152 |
+
} ), {
|
153 |
...acc,
|
154 |
[channel]: {
|
155 |
...data,
|
156 |
audience: audience[channel] || 0
|
157 |
}
|
158 |
+
})), {})
|
159 |
+
this.channel = this.channels[this.channel.id]
|
160 |
},
|
161 |
fullscreen() {
|
162 |
if (this.video.requestFullscreen) {
|
|
|
208 |
document.addEventListener("click", handleActivity)
|
209 |
document.addEventListener("mousemove", handleActivity)
|
210 |
|
211 |
+
this.checkAudience()
|
212 |
setInterval(() => {
|
213 |
this.checkAudience()
|
214 |
}, 2000)
|