@@ -48,40 +48,39 @@ const getSingleMessage =
4848 ( messageId : number ) : ThunkAction < Promise < Message | null >> =>
4949 async ( dispatch , getState ) => {
5050 const state = getState ( ) ;
51-
52- const auth = getAuth ( state ) ;
5351 const messages = getMessages ( state ) ;
54- const zulipFeatureLevel = getZulipFeatureLevel ( state ) ;
55- const allowEditHistory = getRealm ( state ) . allowEditHistory ;
56-
57- // Try to get it from our local data to avoid a server round-trip…
5852 let message = messages . get ( messageId ) ;
53+ if ( message ) {
54+ return message ;
55+ }
5956
60- // …but if we have to, go and ask the server.
6157 // TODO: Give feedback when the server round trip takes longer than
6258 // expected.
6359 // TODO: Let the user cancel the request so we don't force a doNarrow
6460 // after they've given up on tapping the link, and perhaps forgotten
6561 // about it. Like any request, this might take well over a minute to
6662 // resolve, or never resolve.
6763 // TODO: When these are fixed, remove warning in jsdoc.
68- if ( ! message ) {
64+
65+ const auth = getAuth ( state ) ;
66+ const zulipFeatureLevel = getZulipFeatureLevel ( state ) ;
67+ const allowEditHistory = getRealm ( state ) . allowEditHistory ;
68+
69+ if ( zulipFeatureLevel < 120 ) {
6970 // TODO(server-5.0): Simplify; simplify jsdoc to match.
70- if ( zulipFeatureLevel < 120 ) {
71- // api.getSingleMessage won't give us the message's stream and
72- // topic; see there.
73- return null ;
74- }
75- try {
76- message = await api . getSingleMessage (
77- auth ,
78- { message_id : messageId } ,
79- zulipFeatureLevel ,
80- allowEditHistory ,
81- ) ;
82- } catch {
83- return null ;
84- }
71+ // api.getSingleMessage won't give us the message's stream and
72+ // topic; see there.
73+ return null ;
74+ }
75+ try {
76+ message = await api . getSingleMessage (
77+ auth ,
78+ { message_id : messageId } ,
79+ zulipFeatureLevel ,
80+ allowEditHistory ,
81+ ) ;
82+ } catch {
83+ return null ;
8584 }
8685
8786 // The FL 120 condition on calling api.getSingleMessage should ensure
@@ -91,7 +90,6 @@ const getSingleMessage =
9190 logging . error ( '`message` from api.getSingleMessage unexpectedly falsy' ) ;
9291 return null ;
9392 }
94-
9593 return message ;
9694 } ;
9795
0 commit comments