Fable will fix it!
This commit is contained in:
@@ -1416,8 +1416,22 @@ const SUGGESTIONS = {
|
||||
]
|
||||
};
|
||||
|
||||
export function getSuggestion(type) {
|
||||
const arr = SUGGESTIONS[type];
|
||||
export function getSuggestion(type, exclude = []) {
|
||||
let arr = SUGGESTIONS[type];
|
||||
if (!arr) return "";
|
||||
const taken = new Set(exclude.map(s => s.trim().toLowerCase()));
|
||||
const available = arr.filter(s => !taken.has(s.trim().toLowerCase()));
|
||||
if (available.length > 0) arr = available;
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
}
|
||||
|
||||
// Draws `count` distinct suggestions from a pool.
|
||||
export function getSuggestions(type, count) {
|
||||
const picked = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const s = getSuggestion(type, picked);
|
||||
if (!s) break;
|
||||
picked.push(s);
|
||||
}
|
||||
return picked;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user