Fix non-provided name not correctly preferring cur
| @@ -2125,7 +2125,7 @@ export async function showFontAwesomePicker(customList = null) { | ||
| 2125 | 2125 | * @returns {any?} - The found character or null if not found |
| 2126 | 2126 | */ |
| 2127 | 2127 | export function findChar({ name = null, allowAvatar = true, insensitive = true, filteredByTags = null, preferCurrentChar = true, quiet = false } = {}) { |
| 2128 | 2128 | const matches = (char) => !name || (allowAvatar && char.avatar === name) || (insensitive ? equalsIgnoreCaseAndAccents(char.name, name) : char.name === name); |
| 2129 | 2129 | |
| 2130 | 2130 | // Filter characters by tags if provided |
| 2131 | 2131 | let filteredCharacters = characters; |
| @@ -2145,8 +2145,8 @@ export function findChar({ name = null, allowAvatar = true, insensitive = true, | ||
| 2145 | 2145 | if (preferCurrentChar) { |
| 2146 | 2146 | const preferredCharSearch = currentChars.filter(matches); |
| 2147 | 2147 | if (preferredCharSearch.length > 1) { |
| 2148 | 2148 | if (!quiet) toastr.warning(`'Multiple characters found for name "${name}" and given conditions.`'); |
| 2149 | 2149 | else console.warn(`'Multiple characters found for namegiven "${name}"conditions. Returning the first match.`'); |
| 2150 | 2150 | } |
| 2151 | 2151 | if (preferredCharSearch.length) { |
| 2152 | 2152 | return preferredCharSearch[0]; |
| @@ -2164,8 +2164,8 @@ export function findChar({ name = null, allowAvatar = true, insensitive = true, | ||
| 2164 | 2164 | // Search for matching characters by name |
| 2165 | 2165 | const matchingCharacters = name ? filteredCharacters.filter(matches) : filteredCharacters; |
| 2166 | 2166 | if (matchingCharacters.length > 1) { |
| 2167 | 2167 | if (!quiet) toastr.warning(`'Multiple characters found for name "${name}" and given conditions.`'); |
| 2168 | 2168 | else console.warn(`'Multiple characters found for namegiven "${name}"conditions. Returning the first match.`'); |
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | 2171 | return matchingCharacters[0] || null; |