FIX: fixed issues loading content on new accounts
This commit is contained in:
@@ -15,7 +15,7 @@ const StreamerRoute: React.FC = () => {
|
|||||||
const response = await fetch(`/api/user/${streamerName}/status`);
|
const response = await fetch(`/api/user/${streamerName}/status`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setIsLive(Boolean(data.is_live));
|
setIsLive(Boolean(data.is_live));
|
||||||
setStreamId(data.most_recent_stream);
|
setStreamId(data.user_id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error checking stream status:", error);
|
console.error("Error checking stream status:", error);
|
||||||
setIsLive(false);
|
setIsLive(false);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from flask import Blueprint, jsonify, session
|
from flask import Blueprint, jsonify
|
||||||
from database.database import Database
|
from database.database import Database
|
||||||
from .socket import socketio
|
from .socket import socketio
|
||||||
from flask_socketio import emit, join_room, leave_room
|
from flask_socketio import emit, join_room, leave_room
|
||||||
@@ -7,7 +7,7 @@ from utils.user_utils import get_user_id
|
|||||||
|
|
||||||
chat_bp = Blueprint("chat", __name__)
|
chat_bp = Blueprint("chat", __name__)
|
||||||
|
|
||||||
# <---------------------- ROUTES NEEDS TO BE CHANGED TO VIDEO OR DELETED AS DEEMED APPROPRIATE ---------------------->
|
#NOTE: <---------------------- ROUTES NEEDS TO BE CHANGED TO VIDEO OR DELETED AS DEEMED APPROPRIATE ---------------------->
|
||||||
|
|
||||||
@socketio.on("connect")
|
@socketio.on("connect")
|
||||||
def handle_connection() -> None:
|
def handle_connection() -> None:
|
||||||
@@ -23,6 +23,7 @@ def handle_join(data) -> None:
|
|||||||
Allow a user to join the chat of the stream they are watching.
|
Allow a user to join the chat of the stream they are watching.
|
||||||
"""
|
"""
|
||||||
stream_id = data.get("stream_id")
|
stream_id = data.get("stream_id")
|
||||||
|
print(f"Stream ID GLORP: {stream_id}", flush=True)
|
||||||
if stream_id:
|
if stream_id:
|
||||||
join_room(stream_id)
|
join_room(stream_id)
|
||||||
num_viewers = len(list(socketio.server.manager.get_participants("/", stream_id)))
|
num_viewers = len(list(socketio.server.manager.get_participants("/", stream_id)))
|
||||||
@@ -117,4 +118,16 @@ def save_chat(chatter_id, stream_id, message):
|
|||||||
db.execute("""
|
db.execute("""
|
||||||
INSERT INTO chat (chatter_id, stream_id, message)
|
INSERT INTO chat (chatter_id, stream_id, message)
|
||||||
VALUES (?, ?, ?);""", (chatter_id, stream_id, message))
|
VALUES (?, ?, ?);""", (chatter_id, stream_id, message))
|
||||||
db.close_connection()
|
db.close_connection()
|
||||||
|
|
||||||
|
def update_viewers(stream_id, num_viewers):
|
||||||
|
"""
|
||||||
|
Live Update the number of viewers in the stream to be
|
||||||
|
displayed in the homepage or discovery pages
|
||||||
|
"""
|
||||||
|
db = Database()
|
||||||
|
db.execute("""
|
||||||
|
UPDATE streams
|
||||||
|
SET num_viewers = ?
|
||||||
|
WHERE user_id = ?;
|
||||||
|
""")
|
||||||
@@ -128,7 +128,8 @@ def user_live_status(username):
|
|||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"is_live": is_live,
|
"is_live": is_live,
|
||||||
"most_recent_stream": most_recent_vod
|
"most_recent_stream": most_recent_vod,
|
||||||
|
"user_id": user_id
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ def get_latest_vod(user_id: int):
|
|||||||
Returns data of the most recent stream by a streamer
|
Returns data of the most recent stream by a streamer
|
||||||
"""
|
"""
|
||||||
with Database() as db:
|
with Database() as db:
|
||||||
latest_vod = db.fetchone("""SELECT * FROM vods WHERE user_id = ? ORDER BY vod_id DESC LIMIT 1;""", (user_id,))
|
latest_vod = db.fetchone("""SELECT * FROM vods WHERE user_id = ? ORDER BY vod_id DESC;""", (user_id,))
|
||||||
return latest_vod
|
return latest_vod
|
||||||
|
|
||||||
def get_user_vods(user_id: int):
|
def get_user_vods(user_id: int):
|
||||||
|
|||||||
Reference in New Issue
Block a user