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

Make forum-post-cooldown use auto-follow-topic's logic #7273

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

Conversation

mybearworld
Copy link
Contributor

Resolves #6926
Probably resolves #7269
Resolves (possibly) #6914 (not sure about this one, I can't seem to replicate that issue even on stable)

Changes

Turn auto-follow-topic into a module, and make forum-post-cooldown use it.

Reason for changes

Improving forum-post-cooldown.

Tests

Tested in Edge.

@WorldLanguages WorldLanguages self-assigned this Mar 17, 2024
@WorldLanguages WorldLanguages added type: bug A bug in the addon loader, or in a specific addon scope: addon Related to one or multiple addons labels Mar 17, 2024
Comment on lines +30 to +31
export const onNonSuccessfulPost = (callback) => {
if (hasTopic && !success) callback(topicID);
Copy link
Member

Choose a reason for hiding this comment

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

This still isn't convincing to me. Shouldn't this check for postError()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

postError() is called when setting the success variable.

Copy link
Member

Choose a reason for hiding this comment

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

success being true does guarantee there wasn't any post errors. However, success being false tells us nothing about whether there was a post error or not. Again, how do we want to define a "non successful post"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A "non-succesful post" is a post that has been attempted to be posted by the user, but instead of it being posted, an error message was shown.

Copy link
Member

Choose a reason for hiding this comment

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

The variable success is true, if and only if, hasTopic && !postError() is true
That is, !success is true if either hasTopic if false, postError() is true, or both at the same time

To see if there's a non-successful post, you evaluate hasTopic && !success.
But as said above, this is equivalent to hasTopic && (!hasTopic || postError())
Of course, hasTopic cannot be true and false at the same time, so the condition you end up checking is hasTopic && postError()

So I guess your code is equivalent to what I would expect (I would need to check again), but I found it quite confusing!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I just leave out the success variable in favor of calling postError directly?

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export const onNonSuccessfulPost = (callback) => {
if (hasTopic && !success) callback(topicID);
export const onNonSuccessfulPost = (callback) => {
if (postError()) callback(topicID);

I guess this would work as you expect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: addon Related to one or multiple addons type: bug A bug in the addon loader, or in a specific addon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

forum-post-countdown is inaccurate forum-post-countdown also starts the countdown on other errors
2 participants