MCPcopy Create free account
hub / github.com/dailydotdev/apps / groupPostOptions

Function groupPostOptions

packages/shared/src/features/posts/postOptionGroups.ts:40–61  ·  view source on GitHub ↗
(
  options: MenuItemProps[],
)

Source from the content-addressed store, hash-verified

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.
40export 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};

Callers 2

PostOptionsSheetFunction · 0.90

Calls 2

sortByFunction · 0.85
isPrimaryFunction · 0.85

Tested by

no test coverage detected