Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Enhancement: PostBlock blocks instantly. #898

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

Conversation

alleycatboy
Copy link
Contributor

Description

Addresses issue #894 reported by @marcustyphoon by using the same caching as Seen Posts to block posts during soft navigation.

Testing steps

Enable PostBlock script and use as normal.

src/scripts/postblock.js Outdated Show resolved Hide resolved
src/scripts/postblock.js Outdated Show resolved Hide resolved
@alleycatboy alleycatboy force-pushed the enhancement_postblock_block_instantly branch from 384e6af to 713c54b Compare December 11, 2022 22:19
@alleycatboy
Copy link
Contributor Author

Now using CSS selectors instead of directly adding/removing classes as suggested here.

@alleycatboy alleycatboy force-pushed the enhancement_postblock_block_instantly branch 2 times, most recently from 0de226f to 384e6af Compare December 31, 2022 20:04
@AprilSylph AprilSylph linked an issue Jan 8, 2023 that may be closed by this pull request
Copy link
Collaborator

@marcustyphoon marcustyphoon left a comment

Choose a reason for hiding this comment

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

The GitHub review UI apparently doesn't let me make a code suggestion when there's a CI warning in the "files changed" interface, but as per that warning, you can combine the two imports from the same file.

Copy link
Collaborator

@marcustyphoon marcustyphoon left a comment

Choose a reason for hiding this comment

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

postblock.css can be removed as part of this, as it is no longer used! Addtionally:

async (postElement) => {
const { rebloggedRootId } = await timelineObject(postElement);
const rootID = rebloggedRootId || postElement.dataset.id;
postElement.dataset.targetRootId = rootID;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These need to be removed in clean()!

const styleElement = buildStyle();
const buildCss = () =>
`:is(${blockedPostRootIDs
.map((rootId) => `[data-target-root-id="${rootId}"]`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we should target the article elements within the post elements, not the post elements themselves, to avoid breaking J/K scrolling.

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.

PostBlock: Block posts instantly (minor)
2 participants