Skip to content

Conversation

@Markus87
Copy link

Summary

This adds a input field in the settings of the app which allows the user to drop articles if their title matches the regex.

I am aware some of this checklist may not be perfect yet, but I doubt the changes will make it anyway like this.
It would be cool if somebody who actually understands this app better than me to have a look if this is permissible at all.

Checklist

@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/store/app.ts 0.00% 2 Missing ⚠️
src/components/modals/AppSettingsDialog.vue 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a new feature allowing users to filter out articles from their RSS feeds based on a regex pattern matching the article title. Users can configure the regex pattern through a new input field in the app settings.

Changes:

  • Added frontend state management for titleFilterRegex setting in the Vuex store
  • Added a text input field in the app settings dialog for users to enter the regex pattern
  • Implemented backend filtering logic that skips articles matching the regex during feed fetching
  • Registered the new setting in the PageController to load the initial state

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.

File Description
src/store/app.ts Adds titleFilterRegex to app state, getters, and mutations for storing the regex pattern
src/components/modals/AppSettingsDialog.vue Adds NcTextField component for users to input the regex pattern in settings
lib/Service/FeedServiceV2.php Implements article filtering logic using the regex pattern during feed fetch operations
lib/Controller/PageController.php Registers titleFilterRegex setting to be loaded on page initialization
Comments suppressed due to low confidence (1)

lib/Service/FeedServiceV2.php:425

  • Logical bug: The unread count calculation will be incorrect when articles are filtered out. The code at lines 415-423 counts unread items from the $items array, but filtered items (skipped via continue at line 395) are still present in this array - they're just not inserted into the database. This means the unread count will include filtered items that don't actually exist in the database.

To fix this, either:

  1. Remove filtered items from the $items array instead of using continue, or
  2. Calculate the unread count only from successfully inserted items, or
  3. Track inserted items in a separate array and count from that
	foreach (array_reverse($items) as &$item) {
            $filterBy = $this->userConfig->getValueString( $feed->getUserId(), 'news', 'titleFilterRegex');
            if( $item->getTitle() !== null && !empty($filterBy ) && preg_match( $filterBy, $item->getTitle() ) ) {
                $this->logger->trace( 'Item filtered: {title}', [ 'title' => $item->getTitle() ] );
                continue;
            }


            $item->setFeedId($feed->getId())
                ->setBody($this->purifier->purify($item->getBody()));

            // update modes: 0 nothing, 1 set unread
            if ($feed->getUpdateMode() === Feed::UPDATE_MODE_NORMAL) {
                $item->setUnread(true);
            }

            $item = $this->itemService->insertOrUpdate($item);
        }


        // mark feed as successfully updated
        $feed->setUpdateErrorCount(0);
        $feed->setLastUpdateError(null);

        $unreadCount = 0;
        array_map(
            function (Item $item) use (&$unreadCount): void {
                if ($item->isUnread()) {
                    $unreadCount++;
                }
            },
            $items
        );

        return $this->mapper->update($feed)->setUnreadCount($unreadCount);

@Markus87 Markus87 marked this pull request as draft January 31, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants