Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ability to watch threads via filters #2925

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

paradox460
Copy link
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
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
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
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
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 ?

Module scans current filters, and on finding any watch filters,
periodically (every 5m) scans all boards set by said filters, and adds
any matches to the WatchList.

The other, dumb matching is still present, as it lets users get
watches without specifying a board, and wont do anything to matches we
already have from this
@paradox460
Copy link
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

acc[k] ?= []
acc[k].push(v)
acc
, {}
Copy link
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.

"No.#{parsedThread.ID}"
)
excerpt = "/#{boardID}/ - #{excerptName}"
excerpt = "#{excerpt[...70]}..." if excerpt.length > 73
Copy link
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

'AutoWatcher'
onLoadEnd,
{timeout: $.MINUTE, ajax}
)
Copy link
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.

@@ -168,6 +173,9 @@ Filter =
$.addClass @nodes.root, hl...
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
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
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.

# for free to join this conversation on GitHub. Already have an account? # 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