diff --git a/pages/audiocast.py b/pages/audiocast.py deleted file mode 100644 index d3f701a..0000000 --- a/pages/audiocast.py +++ /dev/null @@ -1,63 +0,0 @@ -import asyncio -from typing import cast - -import pyperclip -import streamlit as st -from src.utils.main_utils import get_audiocast -from src.utils.render_audiocast_utils import ( - GenerateAudiocastDict, - navigate_to_home, - render_audiocast_handler, -) - - -async def render_audiocast_page(): - st.set_page_config(page_title="Audiora | Share Page", page_icon="🎧") - - session_id = st.query_params.get("session_id") - - if session_id: - # Display audiocast content - st.title("🎧 Audiora") - st.subheader("Share Page ") - st.markdown(f"##### Viewing audiocast: _{session_id}_") - - try: - with st.spinner("Loading audiocast..."): - audiocast = cast(GenerateAudiocastDict, get_audiocast(session_id)) - - share_url = render_audiocast_handler(session_id, audiocast) - - share_col, restart_row = st.columns(2, vertical_alignment="bottom") - - with share_col: - if st.button("Copy Share link", use_container_width=True): - pyperclip.copy(share_url) - st.session_state.show_copy_success = True - - with restart_row: - if st.button("Create your Audiocast", use_container_width=True): - navigate_to_home() - - if st.session_state.get("show_copy_success", False): - st.session_state.show_copy_succes = False - st.success("Share link copied successfully!", icon="✅") - - if audiocast["created_at"]: - st.markdown(f"> Created: {audiocast["created_at"]}") - - except Exception as e: - st.error(f"Error loading audiocast: {str(e)}") - else: - st.warning("Audiocast ID is missing in the URL. Expected URL format: ?session_id=your-audiocast-id") - - st.markdown("---") - - col1, _ = st.columns([3, 5]) - with col1: - if st.button("← Back to Home", use_container_width=True): - navigate_to_home() - - -if __name__ == "__main__": - asyncio.run(render_audiocast_page()) diff --git a/utils_pkg/session_manager.py b/utils_pkg/session_manager.py index 0c38183..370c0b2 100644 --- a/utils_pkg/session_manager.py +++ b/utils_pkg/session_manager.py @@ -44,6 +44,7 @@ def _update(self, data: Dict): return self._update_document(self.collection, self.doc_id, data) def data(self) -> SessionModel | None: + """Get session data""" doc = self._get_document(self.collection, self.doc_id) data = doc.to_dict() @@ -75,9 +76,7 @@ def _update_title(self, title: str): return self._update({"metadata.title": title}) def _add_chat(self, chat: SessionChatMessage): - return self._update_document( - self.collection, self.doc_id, {"chats": arrayUnion([chat.__dict__])} - ) + return self._update_document(self.collection, self.doc_id, {"chats": arrayUnion([chat.__dict__])}) def _delete_chat(self, chat_id: str): doc = self._get_document(self.collection, self.doc_id) @@ -120,6 +119,7 @@ def _get_chats(self) -> List[SessionChatMessage]: ] def subscribe_to_metadata_info(self, callback: Callable): + """Subscribe to metadata.info""" doc_ref = self._get_collection(self.collection).document(self.doc_id) def on_snapshot(doc_snapshot, _changes, _read_time):