Skip to content

Add ability to watch threads via filters#2925

Closed
paradox460 wants to merge 0 commit intoccd0:masterfrom
paradox460:master
Closed

Add ability to watch threads via filters#2925
paradox460 wants to merge 0 commit intoccd0:masterfrom
paradox460:master

Conversation

@paradox460
Copy link
Copy Markdown
Collaborator

Adds the ability to make a filter trigger a thread watch, on use of the watch modifier for filters.

Ex:

Subject

/CSG/i;boards:g;watch # watch CSG threads on /g/ automatically

Fixes #1471, #2361, #2490, and probably many more

@saxamaphone69
Copy link
Copy Markdown
Collaborator

I feel like https://find.4chan.org/ could be utilised to do something here.

https://boards.4chan.org/search?#/%224chan%20x%22

That way it would search all of 4chan, or could filter per board.

@paradox460
Copy link
Copy Markdown
Collaborator Author

Probably not a bad idea, but would require a lot more work. This one can sort of piggy-back off the existing infastructure

@ccd0
Copy link
Copy Markdown
Owner

ccd0 commented Feb 6, 2021

The native extension version queries the board's catalog.json when the thread watcher is updated whereas this only adds it to your watchlist if you actually visit a page containing the thread. Do you still find this useful? If so, it could be extended to query catalog.json in the future by adding some code to ThreadWatcher.parseBoard. But the present limitation should be documented.

@paradox460
Copy link
Copy Markdown
Collaborator Author

paradox460 commented Feb 6, 2021

I'll look into getting it to add some checks to the parseBoard call, doesn't sound too difficult. I normally browse in catalog mode anyway, and while testing got every thread on /v/ added to my watcher.


Looking over it, seems like the catalog.json is called rather infrequently, via ThreadWatcher.fetchBoard. Would there be a better place to hook into for getting all threads of a board (such as Index.update), or would adding a periodic (configurable, say every 5 mins default) task that uses catalog.json be an acceptable solution ?

@paradox460
Copy link
Copy Markdown
Collaborator Author

I've added a module that works similarly to how the Native Extensions auto watch works.

You have to have a boards value set for the filter. It parses this and uses it to build a list of boards to fetch the catalog(s) from. It then fetches these catalogs, scans them, and adds each match to the ThreadWatcher.

If the user does not specify boards, then it works like it did when I originally opened this PR; it only scans where the user visits. Useful for catching threads you care about on boards you dont visit often, or threads that have comments IN them that are of interest to you

Comment thread src/Monitoring/AutoWatcher.coffee Outdated
acc[k] ?= []
acc[k].push(v)
acc
, {}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Needs $.dict() [which calls Object.create(null)] instead of {} here.
Should also deduplicate boards and not just sites, and ignore "siteID/*" as a board.

Comment thread src/Monitoring/AutoWatcher.coffee Outdated
"No.#{parsedThread.ID}"
)
excerpt = "/#{boardID}/ - #{excerptName}"
excerpt = "#{excerpt[...70]}..." if excerpt.length > 73
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We should avoid duplicating the code in Get.threadExcerpt. Instead we should make Get.threadExcerpt handle posts from JSON. The comment could be dealt with similar to how Filter does it, in this case using parseCommentDisplay in preference to parseComment if available to filter junk out of the comment:
https://github.com/ccd0/4chan-x/blob/1.14.21.3/src/Filtering/Filter.coffee#L219

Comment thread src/Monitoring/AutoWatcher.coffee Outdated
'AutoWatcher'
onLoadEnd,
{timeout: $.MINUTE, ajax}
)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm wondering if it's possible to combine these periodic fetches with ThreadWatcher's periodic fetches so that less fetches have to take place, but that might be too much complexity.

Comment thread src/Filtering/Filter.coffee Outdated
if noti and Unread.posts and (@ID > Unread.lastReadPost) and not QuoteYou.isYou(@)
Unread.openNotification @, ' triggered a notification filter'
if watch and !ThreadWatcher.isWatched(@thread)
ThreadWatcher.add(@thread)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This watches the thread if it sees any reply to the thread that matches the filter. Is that intentional?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. I figure they could have op: only to match starting posts.

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.

Auto-watch threads highlighted with filter regex

3 participants