@@ -904,7 +904,8 @@ def mouse_event(
904
904
return super ().mouse_event (size , event , button , col , row , focus )
905
905
906
906
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 :
908
909
if self .message ["type" ] == "private" :
909
910
self .model .controller .view .write_box .private_box_view (
910
911
recipient_user_ids = self .recipient_ids ,
@@ -923,7 +924,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
923
924
)
924
925
else :
925
926
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 :
927
928
if self .message ["type" ] == "private" :
928
929
self .model .controller .narrow_to_user (
929
930
recipient_emails = self .recipient_emails ,
@@ -934,7 +935,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
934
935
stream_name = self .stream_name ,
935
936
contextual_message_id = self .message ["id" ],
936
937
)
937
- elif is_command_key ("TOGGLE_NARROW" , key ):
938
+ elif is_command_key ("TOGGLE_NARROW" , key ) and not is_in_empty_narrow :
938
939
self .model .unset_search_narrow ()
939
940
if self .message ["type" ] == "private" :
940
941
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]:
958
959
topic_name = self .topic_name ,
959
960
contextual_message_id = self .message ["id" ],
960
961
)
961
- elif is_command_key ("TOPIC_NARROW" , key ):
962
+ elif is_command_key ("TOPIC_NARROW" , key ) and not is_in_empty_narrow :
962
963
if self .message ["type" ] == "private" :
963
964
self .model .controller .narrow_to_user (
964
965
recipient_emails = self .recipient_emails ,
@@ -974,20 +975,20 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
974
975
self .model .controller .narrow_to_all_messages (
975
976
contextual_message_id = self .message ["id" ]
976
977
)
977
- elif is_command_key ("REPLY_AUTHOR" , key ):
978
+ elif is_command_key ("REPLY_AUTHOR" , key ) and not is_in_empty_narrow :
978
979
# All subscribers from recipient_ids are not needed here.
979
980
self .model .controller .view .write_box .private_box_view (
980
981
recipient_user_ids = [self .message ["sender_id" ]],
981
982
)
982
- elif is_command_key ("MENTION_REPLY" , key ):
983
+ elif is_command_key ("MENTION_REPLY" , key ) and not is_in_empty_narrow :
983
984
self .keypress (size , primary_key_for_command ("REPLY_MESSAGE" ))
984
985
mention = f"@**{ self .message ['sender_full_name' ]} ** "
985
986
self .model .controller .view .write_box .msg_write_box .set_edit_text (mention )
986
987
self .model .controller .view .write_box .msg_write_box .set_edit_pos (
987
988
len (mention )
988
989
)
989
990
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 :
991
992
self .keypress (size , primary_key_for_command ("REPLY_MESSAGE" ))
992
993
993
994
# To correctly quote a message that contains quote/code-blocks,
@@ -1015,7 +1016,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
1015
1016
self .model .controller .view .write_box .msg_write_box .set_edit_text (quote )
1016
1017
self .model .controller .view .write_box .msg_write_box .set_edit_pos (len (quote ))
1017
1018
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 :
1019
1020
# User can't edit messages of others that already have a subject
1020
1021
# For private messages, subject = "" (empty string)
1021
1022
# 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]:
1119
1120
write_box .header_write_box .focus_col = write_box .FOCUS_HEADER_BOX_TOPIC
1120
1121
1121
1122
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 :
1123
1124
self .model .controller .show_msg_info (
1124
1125
self .message , self .topic_links , self .message_links , self .time_mentions
1125
1126
)
1126
- elif is_command_key ("ADD_REACTION" , key ):
1127
+ elif is_command_key ("ADD_REACTION" , key ) and not is_in_empty_narrow :
1127
1128
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 :
1129
1130
self .model .controller .show_msg_sender_info (self .message ["sender_id" ])
1130
1131
return key
0 commit comments