chore: Refactors towards shared menu component (#4445)

This commit is contained in:
Tom Moor
2022-11-19 13:15:38 -08:00
committed by GitHub
parent 924b554281
commit ae6855f3df
21 changed files with 186 additions and 194 deletions

View File

@@ -3,7 +3,9 @@ import { MenuItem } from "../types";
type Item = MenuItem | EmbedDescriptor;
export default function filterExcessSeparators(items: Item[]): Item[] {
export default function filterExcessSeparators<T extends Item>(
items: T[]
): T[] {
return items
.reduce((acc, item) => {
// trim separator if the previous item was a separator
@@ -14,7 +16,7 @@ export default function filterExcessSeparators(items: Item[]): Item[] {
return acc;
}
return [...acc, item];
}, [] as Item[])
}, [] as T[])
.filter((item, index, arr) => {
if (
item.name === "separator" &&