@@ -73,6 +73,7 @@ import {
7373 resolveThreadListV2Status ,
7474 resolveThreadListV2ProviderDrivers ,
7575 resolveThreadListV2SwipeActions ,
76+ layoutThreadListV2RowMenuActions ,
7677 type ThreadListV2Status ,
7778} from "./threadListV2" ;
7879import { QueuedMessageIcon } from "./queued-message-icon" ;
@@ -830,9 +831,9 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
830831 ] ,
831832 [ snoozePresets ] ,
832833 ) ;
833- const arrangementMenuItems = useMemo < MenuAction [ ] > (
834- ( ) => [
835- ... ( props . reorderSupported === true
834+ const reorderMenuItems = useMemo < MenuAction [ ] > (
835+ ( ) =>
836+ props . reorderSupported === true
836837 ? [
837838 { id : "arrange" , title : "Arrange threads…" , image : "line.3.horizontal" } ,
838839 {
@@ -848,22 +849,19 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
848849 attributes : { disabled : props . canMoveDown !== true } ,
849850 } satisfies MenuAction ,
850851 ]
851- : [ ] ) ,
852- ...( props . pinningSupported
852+ : [ ] ,
853+ [ props . canMoveDown , props . canMoveUp , props . reorderSupported ] ,
854+ ) ;
855+ const pinMenuItems = useMemo < MenuAction [ ] > (
856+ ( ) =>
857+ props . pinningSupported
853858 ? [
854859 thread . pinnedAt != null
855860 ? { id : "unpin" , title : "Unpin" , image : "pin.slash" }
856861 : { id : "pin" , title : "Pin" , image : "pin" } ,
857862 ]
858- : [ ] ) ,
859- ] ,
860- [
861- props . canMoveDown ,
862- props . canMoveUp ,
863- props . reorderSupported ,
864- props . pinningSupported ,
865- thread . pinnedAt ,
866- ] ,
863+ : [ ] ,
864+ [ props . pinningSupported , thread . pinnedAt ] ,
867865 ) ;
868866 const autoSettleMenuItems = useMemo < MenuAction [ ] > (
869867 ( ) =>
@@ -911,66 +909,90 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
911909 ] ,
912910 [ canTurnIntoProject , props . titleRegenerationSupported , thread . runtime , isRegeneratingTitle ] ,
913911 ) ;
914- const snoozableCardMenuActions = useMemo < MenuAction [ ] > (
915- ( ) => [
916- { id : "settle" , title : "Settle" , image : "checkmark" } ,
917- {
918- id : "snooze" ,
919- title : "Snooze" ,
920- image : "clock" ,
921- subactions : snoozePresetActions ,
922- } ,
923- ...arrangementMenuItems ,
924- ...titleMenuItems ,
925- ...autoSettleMenuItems ,
926- LEGACY_MENU_ACTIONS [ 0 ] ! ,
927- { id : "delete" , title : "Delete" , image : "trash" , attributes : { destructive : true } } ,
928- ] ,
929- [ arrangementMenuItems , autoSettleMenuItems , snoozePresetActions , titleMenuItems ] ,
930- ) ;
931- const cardMenuActions = useMemo < MenuAction [ ] > (
932- ( ) => [
933- CARD_MENU_ACTIONS [ 0 ] ! ,
934- ...arrangementMenuItems ,
935- ...titleMenuItems ,
936- ...autoSettleMenuItems ,
937- LEGACY_MENU_ACTIONS [ 0 ] ! ,
938- ...CARD_MENU_ACTIONS . slice ( 1 ) ,
939- ] ,
940- [ arrangementMenuItems , autoSettleMenuItems , titleMenuItems ] ,
941- ) ;
942- const slimMenuActions = useMemo < MenuAction [ ] > (
943- ( ) => [
944- SLIM_MENU_ACTIONS [ 0 ] ! ,
945- ...arrangementMenuItems . filter (
946- ( action ) => action . id !== "move-up" && action . id !== "move-down" ,
947- ) ,
948- ...titleMenuItems ,
949- ...autoSettleMenuItems ,
950- LEGACY_MENU_ACTIONS [ 0 ] ! ,
951- SLIM_MENU_ACTIONS [ 1 ] ! ,
952- ] ,
953- [ arrangementMenuItems , autoSettleMenuItems , titleMenuItems ] ,
954- ) ;
955- const snoozedMenuActions = useMemo < MenuAction [ ] > (
956- ( ) => [
957- SNOOZED_MENU_ACTIONS [ 0 ] ! ,
958- ...titleMenuItems ,
959- ...autoSettleMenuItems ,
960- LEGACY_MENU_ACTIONS [ 0 ] ! ,
961- SNOOZED_MENU_ACTIONS [ 1 ] ! ,
962- ] ,
963- [ autoSettleMenuItems , titleMenuItems ] ,
964- ) ;
965- const legacyMenuActions = useMemo < MenuAction [ ] > (
966- ( ) => [
967- LEGACY_MENU_ACTIONS [ 0 ] ! ,
968- ...arrangementMenuItems ,
969- ...titleMenuItems ,
970- LEGACY_MENU_ACTIONS [ 1 ] ! ,
971- ] ,
972- [ arrangementMenuItems , titleMenuItems ] ,
973- ) ;
912+ const menuActions = useMemo < MenuAction [ ] > ( ( ) => {
913+ const nested = Platform . OS === "ios" ;
914+ const direct : MenuAction [ ] = [
915+ ...( thread . branch
916+ ? [
917+ {
918+ id : "new-thread-on-branch" ,
919+ title : getThreadListV2NewBranchMenuTitle ( thread . branch ) ,
920+ image : "square.and.pencil" ,
921+ } ,
922+ ]
923+ : [ ] ) ,
924+ { id : "copy-thread" , title : "Copy thread" , image : "text.bubble" } ,
925+ { id : "copy-thread-id" , title : "Copy thread ID" , image : "doc.on.doc" } ,
926+ ] ;
927+ if ( snoozedRow ) {
928+ return layoutThreadListV2RowMenuActions ( {
929+ nested,
930+ direct : [ ...direct , SNOOZED_MENU_ACTIONS [ 0 ] ! ] ,
931+ reorder : [ ] ,
932+ pin : [ ] ,
933+ secondary : [
934+ ...titleMenuItems ,
935+ ...autoSettleMenuItems ,
936+ LEGACY_MENU_ACTIONS [ 0 ] ! ,
937+ SNOOZED_MENU_ACTIONS [ 1 ] ! ,
938+ ] ,
939+ } ) ;
940+ }
941+ if ( ! props . settlementSupported ) {
942+ return layoutThreadListV2RowMenuActions ( {
943+ nested,
944+ direct : [ ...direct , LEGACY_MENU_ACTIONS [ 0 ] ! ] ,
945+ reorder : reorderMenuItems ,
946+ pin : pinMenuItems ,
947+ secondary : [ ...titleMenuItems , LEGACY_MENU_ACTIONS [ 1 ] ! ] ,
948+ } ) ;
949+ }
950+ if ( canUnsettle ) {
951+ return layoutThreadListV2RowMenuActions ( {
952+ nested,
953+ direct : [ ...direct , SLIM_MENU_ACTIONS [ 0 ] ! ] ,
954+ reorder : reorderMenuItems . filter (
955+ ( action ) => action . id !== "move-up" && action . id !== "move-down" ,
956+ ) ,
957+ pin : pinMenuItems ,
958+ secondary : [
959+ ...titleMenuItems ,
960+ ...autoSettleMenuItems ,
961+ LEGACY_MENU_ACTIONS [ 0 ] ! ,
962+ SLIM_MENU_ACTIONS [ 1 ] ! ,
963+ ] ,
964+ } ) ;
965+ }
966+ return layoutThreadListV2RowMenuActions ( {
967+ nested,
968+ direct : [
969+ ...direct ,
970+ CARD_MENU_ACTIONS [ 0 ] ! ,
971+ ...( swipeActions . secondary === "snooze"
972+ ? [ { id : "snooze" , title : "Snooze" , image : "clock" , subactions : snoozePresetActions } ]
973+ : [ ] ) ,
974+ ] ,
975+ reorder : reorderMenuItems ,
976+ pin : pinMenuItems ,
977+ secondary : [
978+ ...titleMenuItems ,
979+ ...autoSettleMenuItems ,
980+ LEGACY_MENU_ACTIONS [ 0 ] ! ,
981+ CARD_MENU_ACTIONS [ 1 ] ! ,
982+ ] ,
983+ } ) ;
984+ } , [
985+ autoSettleMenuItems ,
986+ canUnsettle ,
987+ pinMenuItems ,
988+ props . settlementSupported ,
989+ reorderMenuItems ,
990+ snoozePresetActions ,
991+ snoozedRow ,
992+ swipeActions . secondary ,
993+ thread . branch ,
994+ titleMenuItems ,
995+ ] ) ;
974996 const handleMenuAction = useCallback (
975997 ( { nativeEvent } : { readonly nativeEvent : { readonly event : string } } ) => {
976998 if ( nativeEvent . event === "new-thread-on-branch" ) onNewThreadOnBranch ( thread ) ;
@@ -1485,32 +1507,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
14851507 threadTitle = { thread . title }
14861508 >
14871509 { ( close ) => (
1488- < Menu
1489- actions = { [
1490- ...( thread . branch
1491- ? [
1492- {
1493- id : "new-thread-on-branch" ,
1494- title : getThreadListV2NewBranchMenuTitle ( thread . branch ) ,
1495- image : "square.and.pencil" ,
1496- } ,
1497- ]
1498- : [ ] ) ,
1499- { id : "copy-thread" , title : "Copy thread" , image : "text.bubble" } ,
1500- { id : "copy-thread-id" , title : "Copy thread ID" , image : "doc.on.doc" } ,
1501- ...( snoozedRow
1502- ? snoozedMenuActions
1503- : ! props . settlementSupported
1504- ? legacyMenuActions
1505- : canUnsettle
1506- ? slimMenuActions
1507- : swipeActions . secondary === "snooze"
1508- ? snoozableCardMenuActions
1509- : cardMenuActions ) ,
1510- ] }
1511- onPressAction = { handleMenuAction }
1512- shouldOpenOnLongPress
1513- >
1510+ < Menu actions = { menuActions } onPressAction = { handleMenuAction } shouldOpenOnLongPress >
15141511 { rowContent ( close ) }
15151512 </ Menu >
15161513 ) }
0 commit comments