@@ -904,7 +904,8 @@ def mouse_event(
904904 return super ().mouse_event (size , event , button , col , row , focus )
905905
906906 def keypress (self , size : urwid_Size , key : str ) -> Optional [str ]:
907- if is_command_key ("REPLY_MESSAGE" , key ):
907+ is_in_empty_narrow = self .model .controller .is_in_empty_narrow
908+ if is_command_key ("REPLY_MESSAGE" , key ) and not is_in_empty_narrow :
908909 if self .message ["type" ] == "private" :
909910 self .model .controller .view .write_box .private_box_view (
910911 recipient_user_ids = self .recipient_ids ,
@@ -923,7 +924,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
923924 )
924925 else :
925926 self .model .controller .view .write_box .stream_box_view (0 )
926- elif is_command_key ("STREAM_NARROW" , key ):
927+ elif is_command_key ("STREAM_NARROW" , key ) and not is_in_empty_narrow :
927928 if self .message ["type" ] == "private" :
928929 self .model .controller .narrow_to_user (
929930 recipient_emails = self .recipient_emails ,
@@ -934,7 +935,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
934935 stream_name = self .stream_name ,
935936 contextual_message_id = self .message ["id" ],
936937 )
937- elif is_command_key ("TOGGLE_NARROW" , key ):
938+ elif is_command_key ("TOGGLE_NARROW" , key ) and not is_in_empty_narrow :
938939 self .model .unset_search_narrow ()
939940 if self .message ["type" ] == "private" :
940941 if len (self .model .narrow ) == 1 and self .model .narrow [0 ][0 ] == "pm-with" :
@@ -958,7 +959,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
958959 topic_name = self .topic_name ,
959960 contextual_message_id = self .message ["id" ],
960961 )
961- elif is_command_key ("TOPIC_NARROW" , key ):
962+ elif is_command_key ("TOPIC_NARROW" , key ) and not is_in_empty_narrow :
962963 if self .message ["type" ] == "private" :
963964 self .model .controller .narrow_to_user (
964965 recipient_emails = self .recipient_emails ,
@@ -974,20 +975,20 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
974975 self .model .controller .narrow_to_all_messages (
975976 contextual_message_id = self .message ["id" ]
976977 )
977- elif is_command_key ("REPLY_AUTHOR" , key ):
978+ elif is_command_key ("REPLY_AUTHOR" , key ) and not is_in_empty_narrow :
978979 # All subscribers from recipient_ids are not needed here.
979980 self .model .controller .view .write_box .private_box_view (
980981 recipient_user_ids = [self .message ["sender_id" ]],
981982 )
982- elif is_command_key ("MENTION_REPLY" , key ):
983+ elif is_command_key ("MENTION_REPLY" , key ) and not is_in_empty_narrow :
983984 self .keypress (size , primary_key_for_command ("REPLY_MESSAGE" ))
984985 mention = f"@**{ self .message ['sender_full_name' ]} ** "
985986 self .model .controller .view .write_box .msg_write_box .set_edit_text (mention )
986987 self .model .controller .view .write_box .msg_write_box .set_edit_pos (
987988 len (mention )
988989 )
989990 self .model .controller .view .middle_column .set_focus ("footer" )
990- elif is_command_key ("QUOTE_REPLY" , key ):
991+ elif is_command_key ("QUOTE_REPLY" , key ) and not is_in_empty_narrow :
991992 self .keypress (size , primary_key_for_command ("REPLY_MESSAGE" ))
992993
993994 # To correctly quote a message that contains quote/code-blocks,
@@ -1015,7 +1016,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
10151016 self .model .controller .view .write_box .msg_write_box .set_edit_text (quote )
10161017 self .model .controller .view .write_box .msg_write_box .set_edit_pos (len (quote ))
10171018 self .model .controller .view .middle_column .set_focus ("footer" )
1018- elif is_command_key ("EDIT_MESSAGE" , key ):
1019+ elif is_command_key ("EDIT_MESSAGE" , key ) and not is_in_empty_narrow :
10191020 # User can't edit messages of others that already have a subject
10201021 # For private messages, subject = "" (empty string)
10211022 # This also handles the realm_message_content_edit_limit_seconds == 0 case
@@ -1119,12 +1120,12 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
11191120 write_box .header_write_box .focus_col = write_box .FOCUS_HEADER_BOX_TOPIC
11201121
11211122 self .model .controller .view .middle_column .set_focus ("footer" )
1122- elif is_command_key ("MSG_INFO" , key ):
1123+ elif is_command_key ("MSG_INFO" , key ) and not is_in_empty_narrow :
11231124 self .model .controller .show_msg_info (
11241125 self .message , self .topic_links , self .message_links , self .time_mentions
11251126 )
1126- elif is_command_key ("ADD_REACTION" , key ):
1127+ elif is_command_key ("ADD_REACTION" , key ) and not is_in_empty_narrow :
11271128 self .model .controller .show_emoji_picker (self .message )
1128- elif is_command_key ("MSG_SENDER_INFO" , key ):
1129+ elif is_command_key ("MSG_SENDER_INFO" , key ) and not is_in_empty_narrow :
11291130 self .model .controller .show_msg_sender_info (self .message ["sender_id" ])
11301131 return key
0 commit comments