mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 22:19:30 +01:00
[MIRROR] Improves the ForceEvent TGUI Search Function (#26603)
* Improves the ForceEvent TGUI Search Function (#81541) ## About The Pull Request Fixes the search logic about checking for nulls, mostly to prevent it from being broken if something else is wrong. ## Why It's Good For The Game Less bugs, more reliable in the case of errors. ## Changelog 🆑 fix: ForceEvent tgui panel search is more reliable. /🆑 * Improves the ForceEvent TGUI Search Function --------- Co-authored-by: nevimer <77420409+nevimer@users.noreply.github.com>
This commit is contained in:
@@ -21,13 +21,15 @@ const paginateEvents = (events: Event[], maxPerPage: number): Event[][] => {
|
||||
let maxChars = EVENT_PAGE_MAXCHARS;
|
||||
|
||||
for (const event of events) {
|
||||
maxChars -= event.name.length;
|
||||
if (maxChars <= 0) {
|
||||
// would overflow the next line over
|
||||
itemsToAdd = maxPerPage;
|
||||
maxChars = EVENT_PAGE_MAXCHARS - event.name.length;
|
||||
pages.push(page);
|
||||
page = [];
|
||||
if (event.name && typeof event.name === 'string') {
|
||||
maxChars -= event.name.length;
|
||||
if (maxChars <= 0) {
|
||||
// would overflow the next line over
|
||||
itemsToAdd = maxPerPage;
|
||||
maxChars = EVENT_PAGE_MAXCHARS - event.name.length;
|
||||
pages.push(page);
|
||||
page = [];
|
||||
}
|
||||
}
|
||||
page.push(event);
|
||||
itemsToAdd--;
|
||||
@@ -127,7 +129,14 @@ export const EventSection = (props) => {
|
||||
return false;
|
||||
}
|
||||
// remove events not being searched for, if a search is active
|
||||
if (searchQuery && !event.name.toLowerCase().includes(searchQuery)) {
|
||||
if (
|
||||
searchQuery &&
|
||||
event.name &&
|
||||
typeof event.name === 'string' &&
|
||||
searchQuery &&
|
||||
typeof searchQuery === 'string' &&
|
||||
!event.name.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user