@@ -952,7 +952,8 @@ def __init__(self, controller: Any, msg: Any) -> None:
952
952
self .widgets .append (self .build_pile (snapshot , 'Current' ))
953
953
continue
954
954
elif index == 0 :
955
- self .widgets .append (self .build_pile (snapshot , 'Original' ))
955
+ self .widgets .append (self .build_pile (snapshot , 'Original' ,
956
+ 'Posted' ))
956
957
else :
957
958
self .widgets .append (self .build_pile (snapshot ))
958
959
# Add a blank line after an edit block/pile.
@@ -967,27 +968,45 @@ def __init__(self, controller: Any, msg: Any) -> None:
967
968
super ().__init__ (controller , self .widgets , 'MSG_INFO' )
968
969
969
970
def build_pile (self , snapshot : Dict [str , Any ], tag : str = '' ,
970
- ) -> Any :
971
+ author_prefix : str = 'Edited' ) -> Any :
971
972
timestamp = time .ctime (snapshot ['timestamp' ])[:- 5 ]
973
+ author = self .get_author (snapshot ['user_id' ])
972
974
topic = snapshot ['topic' ]
973
975
974
976
if 'prev_topic' in snapshot and topic != snapshot ['prev_topic' ]:
975
977
topic += ' (updated from {})' .format (snapshot ['prev_topic' ])
978
+ if 'prev_content' in snapshot :
979
+ author_prefix += ' and Topic updated'
980
+ else :
981
+ author_prefix = 'Topic updated'
976
982
977
983
header = urwid .Columns ([
978
984
urwid .Text (('edit_topic' , topic )),
979
985
(19 , urwid .Text (('edit_time' , timestamp ))),
980
986
], dividechars = 2 ,
981
987
)
982
988
subheader = urwid .Columns ([
989
+ urwid .Text (('edit_author' ,
990
+ '{} by {}' .format (author_prefix , author ))),
983
991
(18 , urwid .Text (('edit_tag' , '({} Version)' .format (tag ) if tag
984
- else '' ))),
992
+ else '' ), align = 'right' )),
985
993
], dividechars = 2 ,
986
994
)
987
995
message = urwid .Text (snapshot ['content' ])
988
996
return urwid .Pile ([urwid .AttrWrap (header , 'popup_contrast' ), subheader ,
989
997
message ])
990
998
999
+ def get_author (self , user_id : int ) -> str :
1000
+ if self .msg ['sender_id' ] == user_id :
1001
+ return self .msg ['sender_full_name' ]
1002
+ else :
1003
+ for user in self .controller .view .users :
1004
+ if user ['user_id' ] == user_id :
1005
+ return user ['full_name' ]
1006
+ # NOTE: This return statement is redundant and only put here to pass
1007
+ # mypy as a user with `user_id` will always exist.
1008
+ return ''
1009
+
991
1010
def keypress (self , size : urwid_Size , key : str ) -> str :
992
1011
if (is_command_key ('GO_BACK' , key )
993
1012
or is_command_key ('EDIT_HISTORY' , key )):
0 commit comments