support no profile and fresh install
This commit is contained in:
@@ -68,13 +68,20 @@ def register_socketio_handlers(socketio):
|
||||
_started = True
|
||||
profile = active_profile()
|
||||
emit("connected", {"ok": True, "profile": profile})
|
||||
if profile:
|
||||
rows = torrent_cache.snapshot(profile["id"])
|
||||
emit("torrent_snapshot", {"profile_id": profile["id"], "torrents": rows, "summary": cached_summary(profile["id"], rows)})
|
||||
if not profile:
|
||||
# Note: Fresh installs have no rTorrent yet; tell the client to show setup instead of waiting for a snapshot.
|
||||
emit("profile_required", {"ok": True, "profiles": []})
|
||||
return
|
||||
rows = torrent_cache.snapshot(profile["id"])
|
||||
emit("torrent_snapshot", {"profile_id": profile["id"], "torrents": rows, "summary": cached_summary(profile["id"], rows)})
|
||||
|
||||
@socketio.on("select_profile")
|
||||
def handle_select_profile(data):
|
||||
profile_id = int((data or {}).get("profile_id") or 0)
|
||||
if not profile_id:
|
||||
# Note: Ignore empty profile selections created before the first rTorrent profile exists.
|
||||
emit("profile_required", {"ok": True, "profiles": []})
|
||||
return
|
||||
profile = get_profile(profile_id)
|
||||
if not profile:
|
||||
emit("rtorrent_error", {"error": "Profile does not exist"})
|
||||
|
||||
Reference in New Issue
Block a user