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

Various Paginator fixes for disable(), cancel(), and respond methods. #1088

Merged
merged 9 commits into from
Mar 3, 2022
Merged

Various Paginator fixes for disable(), cancel(), and respond methods. #1088

merged 9 commits into from
Mar 3, 2022

Conversation

krittick
Copy link
Contributor

Summary

This adds an additional logic check to see if the Paginator.custom_view is not None when trying to disable or cancel items in a paginator that has no custom view.
Fixes #1082

This also adds a conversion from WebhookMessage and InteractionMessage in Paginator.respond() to assign the actual Message object to Paginator.message instead of the former. This avoids the interaction token expiring and preventing interacting with the message after 15 minutes.

Fixes #1083

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

@krittick krittick added status: awaiting review Awaiting review from a maintainer ext.pages Relating to ext.pages labels Feb 27, 2022
@krittick krittick added this to the v2.0 milestone Feb 27, 2022
@krittick krittick self-assigned this Feb 27, 2022
@krittick
Copy link
Contributor Author

@Ahsoka I've tested these myself, but would you mind testing these fixes to ensure they work for you as well?

@krittick krittick enabled auto-merge February 27, 2022 06:30
@krittick krittick disabled auto-merge February 27, 2022 06:30
@krittick krittick enabled auto-merge (squash) February 27, 2022 06:30
@Ahsoka
Copy link
Contributor

Ahsoka commented Feb 27, 2022

@Ahsoka I've tested these myself, but would you mind testing these fixes to ensure they work for you as well?

Sure I'll test this as soon as I get I chance. I'm working on physics homework at the moment.

@Ahsoka
Copy link
Contributor

Ahsoka commented Feb 27, 2022

@krittick The fix for the disable method removes the error but does not actually disable the paginator. I can still fully access the paginator even after calling the disable method.

This comes down to this condition here:

if self.custom_view and (item not in self.custom_view.children or include_custom):

In English the first part of this condition says unless there is a custom view don't disable any of the children of this paginator.

A proper fix would be:

for item in self.children:
    if include_custom or not self.custom_view: # Might want to explictly check for None instead of using not bool(self.custom_view)
        # We can do that like this: if include_custom or self.custom_view is None:
        item.disabled = True
    elif item not in self.custom_view.children:
        item.disabled = True

@Ahsoka
Copy link
Contributor

Ahsoka commented Feb 27, 2022

I will try to do somewhat rigorous testing of your fix of the expiring web token. Will get to back to you soon.

@krittick
Copy link
Contributor Author

That's what I get for writing code while recovering from surgery, haha. Will fix.

@krittick krittick marked this pull request as draft February 27, 2022 08:55
auto-merge was automatically disabled February 27, 2022 08:55

Pull request was converted to draft

@krittick krittick marked this pull request as ready for review February 27, 2022 10:14
@krittick krittick enabled auto-merge (squash) February 27, 2022 10:14
@krittick
Copy link
Contributor Author

Logic should be fixed now.

Copy link
Contributor

@Ahsoka Ahsoka left a comment

Choose a reason for hiding this comment

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

From the testing I've conducted it appears that this works. I was able to use the paginator after 15 minutes and even after 24 hours as well.

Copy link
Contributor

@Ahsoka Ahsoka left a comment

Choose a reason for hiding this comment

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

This seems fine but I would be weary about using not self.custom_view, if someone ever implements a custom __bool__ method this might be an issue. It's probably best to use self.custom_view is None since there is no reason to not use it (at least from what I can tell).

@krittick krittick disabled auto-merge March 3, 2022 21:20
@krittick krittick merged commit 6474f26 into Pycord-Development:master Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext.pages Relating to ext.pages priority: high High Priority status: awaiting review Awaiting review from a maintainer
Projects
None yet
3 participants