Surn commited on
Commit
8dff93f
·
1 Parent(s): 6e0755a

user_history minor update

Browse files
Files changed (1) hide show
  1. modules/user_history.py +12 -3
modules/user_history.py CHANGED
@@ -18,7 +18,7 @@ Useful links:
18
  Update by Surn (Charles Fettinger)
19
  """
20
 
21
- __version__ = "0.3.7"
22
 
23
  import json
24
  import os
@@ -56,6 +56,14 @@ def get_profile() -> gr.OAuthProfile | None:
56
  gr.OAuthProfile | None: The currently logged-in user's profile, or None if no user is logged in.
57
  """
58
  global user_profile
 
 
 
 
 
 
 
 
59
  return user_profile
60
 
61
  def setup(folder_path: str | Path | None = None, display_type: str = "image_path") -> None:
@@ -399,7 +407,7 @@ def _fetch_user_history(profile: gr.OAuthProfile | None) -> List[Tuple[str, str]
399
  if profile is None:
400
  user_profile = gr.State(None)
401
  return []
402
- username = profile if isinstance(profile, str) else profile["preferred_username"]
403
 
404
  user_profile = gr.State(profile)
405
 
@@ -482,10 +490,11 @@ def _delete_user_history(profile: gr.OAuthProfile | None) -> None:
482
 
483
  def _copy_image(image: Image.Image | np.ndarray | str | Path, dst_folder: Path, uniqueId: str = "") -> Path:
484
  try:
 
485
  """Copy image to the images folder."""
486
  # If image is a string, check if it's a URL.
487
  if isinstance(image, str):
488
- if image.startswith("http://", "https://"):
489
  return download_and_save_image(image, dst_folder)
490
  else:
491
  # Assume it's a local filepath string.
 
18
  Update by Surn (Charles Fettinger)
19
  """
20
 
21
+ __version__ = "0.3.8"
22
 
23
  import json
24
  import os
 
56
  gr.OAuthProfile | None: The currently logged-in user's profile, or None if no user is logged in.
57
  """
58
  global user_profile
59
+ if hasattr(user_profile, "value"):
60
+ val = user_profile.value
61
+ if isinstance(val, (list, tuple)):
62
+ for item in val:
63
+ if item is not None:
64
+ return item
65
+ return None
66
+ return val
67
  return user_profile
68
 
69
  def setup(folder_path: str | Path | None = None, display_type: str = "image_path") -> None:
 
407
  if profile is None:
408
  user_profile = gr.State(None)
409
  return []
410
+ username = profile if isinstance(profile, str) else str(profile["preferred_username"])
411
 
412
  user_profile = gr.State(profile)
413
 
 
490
 
491
  def _copy_image(image: Image.Image | np.ndarray | str | Path, dst_folder: Path, uniqueId: str = "") -> Path:
492
  try:
493
+ dst = dst_folder
494
  """Copy image to the images folder."""
495
  # If image is a string, check if it's a URL.
496
  if isinstance(image, str):
497
+ if image.startswith("http://") or image.startswith("https://"):
498
  return download_and_save_image(image, dst_folder)
499
  else:
500
  # Assume it's a local filepath string.