| @@ 38-48 (lines=11) @@ | ||
| 35 | ||
| 36 | # --- Functions --- |
|
| 37 | ||
| 38 | def load_selected_collections(): |
|
| 39 | """Loads the history of previously pinned collections.""" |
|
| 40 | if os.path.exists(SELECTED_COLLECTIONS_FILE): |
|
| 41 | try: |
|
| 42 | with open(SELECTED_COLLECTIONS_FILE, 'r', encoding='utf-8') as f: |
|
| 43 | data = json.load(f); |
|
| 44 | if isinstance(data, dict): return data |
|
| 45 | else: logging.error(f"Invalid format in {SELECTED_COLLECTIONS_FILE}. Resetting."); return {} |
|
| 46 | except json.JSONDecodeError: logging.error(f"Error decoding {SELECTED_COLLECTIONS_FILE}. Resetting."); return {} |
|
| 47 | except Exception as e: logging.error(f"Error loading {SELECTED_COLLECTIONS_FILE}: {e}. Resetting."); return {} |
|
| 48 | return {} |
|
| 49 | ||
| 50 | def save_selected_collections(selected_collections): |
|
| 51 | """Saves the updated history of pinned collections.""" |
|
| @@ 38-48 (lines=11) @@ | ||
| 35 | ||
| 36 | # --- Functions --- |
|
| 37 | ||
| 38 | def load_selected_collections(): |
|
| 39 | """Loads the history of previously pinned collections.""" |
|
| 40 | if os.path.exists(SELECTED_COLLECTIONS_FILE): |
|
| 41 | try: |
|
| 42 | with open(SELECTED_COLLECTIONS_FILE, 'r', encoding='utf-8') as f: |
|
| 43 | data = json.load(f); |
|
| 44 | if isinstance(data, dict): return data |
|
| 45 | else: logging.error(f"Invalid format in {SELECTED_COLLECTIONS_FILE}. Resetting."); return {} |
|
| 46 | except json.JSONDecodeError: logging.error(f"Error decoding {SELECTED_COLLECTIONS_FILE}. Resetting."); return {} |
|
| 47 | except Exception as e: logging.error(f"Error loading {SELECTED_COLLECTIONS_FILE}: {e}. Resetting."); return {} |
|
| 48 | return {} |
|
| 49 | ||
| 50 | def save_selected_collections(selected_collections): |
|
| 51 | """Saves the updated history of pinned collections.""" |
|