diff --git a/src/void_tools/cli.py b/src/void_tools/cli.py index a9f433d..da10dbc 100644 --- a/src/void_tools/cli.py +++ b/src/void_tools/cli.py @@ -92,6 +92,7 @@ def cmd_sync(args): mapping = {} cursor = None stop_pagination = False + latest_seen_timestamp = "" while not stop_pagination: params = {'limit': min(50, args.limit) if not args.unread_only else 50} @@ -112,6 +113,10 @@ def cmd_sync(args): stop_pagination = True break + # Capture the timestamp of the most recent notification we fetched + if not latest_seen_timestamp or notif.indexed_at > latest_seen_timestamp: + latest_seen_timestamp = notif.indexed_at + local_id = f"notif_{len(inbox)}" handle = notif.author.handle item = { @@ -175,6 +180,7 @@ def cmd_sync(args): with open("inbox.yaml", "w") as f: yaml.dump(inbox, f, sort_keys=False, default_flow_style=False) + mapping["_sync_timestamp"] = latest_seen_timestamp with open(".inbox_mapping.json", "w") as f: json.dump(mapping, f) @@ -368,8 +374,11 @@ def cmd_dispatch(args): config = outbox.get("config", {}) if config.get("mark_seen"): try: - client.app.bsky.notification.update_seen({'seen_at': client.get_current_time_iso()}) - print("Marked notifications as seen.") + seen_at = mapping.get("_sync_timestamp") + if not seen_at: + seen_at = client.get_current_time_iso() + client.app.bsky.notification.update_seen({'seen_at': seen_at}) + print(f"Marked notifications as seen up to {seen_at}.") except Exception as e: print(f"Error marking seen: {e}")