( options: MenuItemProps[], )
| 38 | // 48px rows, and those rows plus Hide on the first level run past that. |
| 39 | // Options keep their handlers; only the grouping is decided here, by id. |
| 40 | export const groupPostOptions = ( |
| 41 | options: MenuItemProps[], |
| 42 | ): PostOptionGroups => { |
| 43 | const owner = options |
| 44 | .filter((option) => ownerOrder.includes(option.id ?? '')) |
| 45 | .sort(sortBy(ownerOrder)); |
| 46 | const hideFirst = owner.length === 0; |
| 47 | const isPrimary = (id: string) => |
| 48 | primaryOrder.includes(id) && (hideFirst || id !== 'hide'); |
| 49 | const primary = options |
| 50 | .filter((option) => isPrimary(option.id ?? '')) |
| 51 | .sort(sortBy(primaryOrder)); |
| 52 | const notInterested = options.filter( |
| 53 | (option) => |
| 54 | notInterestedIds.includes(option.id ?? '') || |
| 55 | (!hideFirst && option.id === 'hide'), |
| 56 | ); |
| 57 | const placed = new Set([...primary, ...notInterested, ...owner]); |
| 58 | const more = options.filter((option) => !placed.has(option)); |
| 59 | |
| 60 | return { primary, notInterested, owner, more }; |
| 61 | }; |
no test coverage detected