Blur gallery images by default, sync progress UI, and add chat/monitor tests
- Blur NSFW media gallery images until hover/reveal - Surface chat sync progress in the dashboard header - Extend chat service, cache, and monitor with delta-media handling - Add tests for chat cooldown, delta media, and monitor flows Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
633bb0ec04
commit
2260388dc8
15 files changed
+675
-41
No files matched your search
+32
-6
@@ -23,6 +23,13 @@ export class MonitorService {
|
||||
const subreddits = this.buildCheckOrder();
|
||||
|
||||
const targetGenders = this.config.reddit.targetGenders;
|
||||
const prioritizeRecent = this.config.reddit.prioritizeRecentPosts;
|
||||
const recentCutoffSec = prioritizeRecent
|
||||
? Math.floor(Date.now() / 1000) - this.config.reddit.recentWindowMinutes * 60
|
||||
: 0;
|
||||
// Older posts found while prioritizing recent ones — used as a fallback
|
||||
// so the bot still has something to do if no recent posts exist anywhere.
|
||||
let fallback: RedditPost | null = null;
|
||||
|
||||
for (const subreddit of subreddits) {
|
||||
try {
|
||||
@@ -62,15 +69,27 @@ export class MonitorService {
|
||||
}
|
||||
|
||||
if (validPosts.length > 0) {
|
||||
this.logger.info(`Found ${validPosts.length} new posts in r/${subreddit.name}`);
|
||||
|
||||
// Sort by creation time (newest first)
|
||||
validPosts.sort((a, b) => b.created_utc - a.created_utc);
|
||||
|
||||
// Return just the first (newest) valid post
|
||||
// This ensures we switch to a different random subreddit on the next poll cycle
|
||||
// instead of processing a batch from the same subreddit
|
||||
return [validPosts[0]];
|
||||
if (prioritizeRecent) {
|
||||
const recent = validPosts.find((p) => p.created_utc >= recentCutoffSec);
|
||||
if (recent) {
|
||||
this.logger.info(`Found ${validPosts.length} new posts in r/${subreddit.name} (recent match)`);
|
||||
return [recent];
|
||||
}
|
||||
// Remember the freshest non-recent candidate as a fallback and
|
||||
// keep scanning other subs for an actually-recent post.
|
||||
if (!fallback || validPosts[0].created_utc > fallback.created_utc) {
|
||||
fallback = validPosts[0];
|
||||
}
|
||||
} else {
|
||||
this.logger.info(`Found ${validPosts.length} new posts in r/${subreddit.name}`);
|
||||
// Return just the first (newest) valid post
|
||||
// This ensures we switch to a different random subreddit on the next poll cycle
|
||||
// instead of processing a batch from the same subreddit
|
||||
return [validPosts[0]];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to fetch posts from r/${subreddit.name}:`, error);
|
||||
@@ -82,6 +101,13 @@ export class MonitorService {
|
||||
}
|
||||
}
|
||||
|
||||
if (fallback) {
|
||||
this.logger.info(
|
||||
`No posts within last ${this.config.reddit.recentWindowMinutes}m — falling back to newest available (r/${fallback.subreddit})`,
|
||||
);
|
||||
return [fallback];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user