powercord-org / powercord

A lightweight @discord client mod focused on simplicity and performance.
MIT License
1.2k stars 147 forks source link

fix: don't crash on command autocomplete #644

Closed katlyn closed 2 years ago

katlyn commented 2 years ago

This commit fixes #643 by using the vanilla Autocomplete.Title component. After testing, there is no regression that I could find from using the unpatched component rather than custom patched version.

GriefMoDz commented 2 years ago

Call it pointless, but the sole purpose of using a custom autocomplete Title component is simply to take into account empty autocomplete titles from which the native component doesn't support.

The following figures show how this is applied through the use of the lmgtfy command with the "Display Autocompletes" setting enabled.

  1. Using the native component (i.e. displays a large empty space where the title would normally be): Figure 1

  2. Using the custom component (i.e. removes the large empty space where the title would normally be): Figure 2

How I would go about fixing this instead, is by wrapping the custom component around an AsyncComponent and making it fallback to an empty container if the Title component isn't found or returns an empty result.

It should end up looking something like this and will additionally help mitigate such crashes from arising again.