Spaces:
Running
Running
internomega-terrablue commited on
Commit Β·
c347aa1
1
Parent(s): 33a151e
Enabling logger for capturing storage error 2
Browse files
app.py
CHANGED
|
@@ -362,12 +362,16 @@ with gr.Blocks(css=CUSTOM_CSS, theme=dark_theme, title="NotebookLM") as demo:
|
|
| 362 |
|
| 363 |
# ββ Auth: on page load βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 364 |
def on_app_load(profile: gr.OAuthProfile | None):
|
|
|
|
| 365 |
if profile is None:
|
| 366 |
return None, gr.update(visible=True), gr.update(visible=False)
|
| 367 |
-
|
| 368 |
state = StorageService.load_user_data(profile.username, profile.name)
|
| 369 |
if state is None:
|
|
|
|
| 370 |
state = create_default_user_data(profile.username, profile.name)
|
|
|
|
|
|
|
| 371 |
return state, gr.update(visible=False), gr.update(visible=True)
|
| 372 |
|
| 373 |
demo.load(
|
|
@@ -440,12 +444,14 @@ with gr.Blocks(css=CUSTOM_CSS, theme=dark_theme, title="NotebookLM") as demo:
|
|
| 440 |
|
| 441 |
# ββ Sidebar: Save ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 442 |
def handle_save(state):
|
|
|
|
| 443 |
if not state:
|
| 444 |
return '<p style="color:#ef4444; font-size:0.8rem;">No data to save.</p>'
|
| 445 |
try:
|
| 446 |
StorageService.save_user_data(state)
|
| 447 |
return '<p style="color:#22c55e; font-size:0.8rem;">Saved successfully!</p>'
|
| 448 |
except Exception as e:
|
|
|
|
| 449 |
return f'<p style="color:#ef4444; font-size:0.8rem;">Save failed: {e}</p>'
|
| 450 |
|
| 451 |
save_btn.click(
|
|
|
|
| 362 |
|
| 363 |
# ββ Auth: on page load βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 364 |
def on_app_load(profile: gr.OAuthProfile | None):
|
| 365 |
+
print(f"[on_app_load] profile={profile}")
|
| 366 |
if profile is None:
|
| 367 |
return None, gr.update(visible=True), gr.update(visible=False)
|
| 368 |
+
print(f"[on_app_load] Loading data for user: {profile.username}")
|
| 369 |
state = StorageService.load_user_data(profile.username, profile.name)
|
| 370 |
if state is None:
|
| 371 |
+
print(f"[on_app_load] No saved data found β creating default")
|
| 372 |
state = create_default_user_data(profile.username, profile.name)
|
| 373 |
+
else:
|
| 374 |
+
print(f"[on_app_load] Loaded {len(state.notebooks)} notebook(s)")
|
| 375 |
return state, gr.update(visible=False), gr.update(visible=True)
|
| 376 |
|
| 377 |
demo.load(
|
|
|
|
| 444 |
|
| 445 |
# ββ Sidebar: Save ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 446 |
def handle_save(state):
|
| 447 |
+
print(f"[handle_save] Called, state={state is not None}")
|
| 448 |
if not state:
|
| 449 |
return '<p style="color:#ef4444; font-size:0.8rem;">No data to save.</p>'
|
| 450 |
try:
|
| 451 |
StorageService.save_user_data(state)
|
| 452 |
return '<p style="color:#22c55e; font-size:0.8rem;">Saved successfully!</p>'
|
| 453 |
except Exception as e:
|
| 454 |
+
print(f"[handle_save] Error: {e}")
|
| 455 |
return f'<p style="color:#ef4444; font-size:0.8rem;">Save failed: {e}</p>'
|
| 456 |
|
| 457 |
save_btn.click(
|