@@ -16,11 +16,8 @@ const useOrangeLine = () => {
1616 const maxMsgID = C . useChatContext ( s => s . meta . maxMsgID )
1717 const metaOrangeShow = maxMsgID > readMsgID
1818 const active = C . useActiveState ( s => s . active )
19-
20- const initOrangeLine = ( ) => {
21- return metaOrangeShow ? readMsgID : 0
22- }
23- const [ orangeLine , setOrangeLine ] = React . useState ( initOrangeLine ( ) )
19+ const initOrangeLine = metaOrangeShow ? readMsgID : 0
20+ const [ orangeLine , setOrangeLine ] = React . useState ( initOrangeLine )
2421 const [ lastCID , setLastCID ] = React . useState ( conversationIDKey )
2522 const [ lastReadMsgID , setLastReadMsgID ] = React . useState ( readMsgID )
2623 const [ metaGood , setMetaGood ] = React . useState ( readMsgID > 0 )
@@ -40,7 +37,7 @@ const useOrangeLine = () => {
4037 if ( lastCID !== conversationIDKey ) {
4138 setLastCID ( conversationIDKey )
4239 setLastReadMsgID ( readMsgID )
43- setOrangeLine ( initOrangeLine ( ) )
40+ setOrangeLine ( initOrangeLine )
4441 }
4542
4643 // not active and we should show?
@@ -57,10 +54,9 @@ const useOrangeLine = () => {
5754 return orangeLine
5855}
5956
60- const NormalWrapper = React . memo ( function NormalWrapper ( ) {
61- const orangeLine = useOrangeLine ( )
57+ const WithOrange = React . memo ( function WithOrange ( p : { orangeLine : number } ) {
6258 return (
63- < OrangeLineContext . Provider value = { orangeLine } >
59+ < OrangeLineContext . Provider value = { p . orangeLine } >
6460 < FocusProvider >
6561 < ScrollProvider >
6662 < Normal />
@@ -69,4 +65,9 @@ const NormalWrapper = React.memo(function NormalWrapper() {
6965 </ OrangeLineContext . Provider >
7066 )
7167} )
68+
69+ const NormalWrapper = React . memo ( function NormalWrapper ( ) {
70+ const orangeLine = useOrangeLine ( )
71+ return < WithOrange orangeLine = { orangeLine } />
72+ } )
7273export default NormalWrapper
0 commit comments