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

fix(client): remove duplication of views in views/all_views #1228

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

Conversation

ooliver1
Copy link
Member

@ooliver1 ooliver1 commented Nov 24, 2024

Summary

Introduced in #843 and discovered in this help thread, the new implementation for retrieving views via the client has duplicated views with multiple components.
This is due to removing the construction of a dictionary internally to make the list unqiue. This PR adds this method back and comments
it to ensure this isn't wrongly removed again.

With the following code, running send_view twice, and all_views once returns 4 views when it should be 2 unique, as seen in the new behaviour below.

class MyView(View):
    @button(label="one")
    async def one(self, button, interaction: Interaction):
        await interaction.response.send_message("one")

    @button(label="two")
    async def two(self, button, interaction: Interaction):
        await interaction.response.send_message("two")

@bot.slash_command()
async def send_view(inter: Interaction):
    await inter.response.send_message("View", view=MyView())

@bot.slash_command()
async def all_views(inter: Interaction):
    views = bot.all_views
    views2 = bot.views(persistent=False)
    await inter.response.send_message(str(views) + "\n" + str(views2))

old and new behaviour

This is a Code Change

  • I have tested my changes.
  • I have updated the documentation to reflect the changes.
  • I have run task pyright and fixed the relevant issues.

@ooliver1 ooliver1 added this to the 3.0 milestone Nov 24, 2024
@ooliver1 ooliver1 added t: bug Type: bug - something isn't working p: high Priority: high - should be worked on as soon as reasonable s: awaiting review Status: the issue or PR is awaiting reviews 3.0 The issue/PR should go for the 3.0 release labels Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 The issue/PR should go for the 3.0 release p: high Priority: high - should be worked on as soon as reasonable s: awaiting review Status: the issue or PR is awaiting reviews t: bug Type: bug - something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant