File tree 4 files changed +36
-2
lines changed
4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,10 @@ export const NoteMetaReadCount = () => {
60
60
{ dividerVertical }
61
61
< span className = { sectionBlockClassName } key = "readcount" >
62
62
< i className = "icon-[mingcute--book-6-line]" />
63
- < span className = "font-medium" > { read } </ span >
63
+
64
+ < span className = "font-medium" >
65
+ < NumberSmoothTransition > { read } </ NumberSmoothTransition >
66
+ </ span >
64
67
</ span >
65
68
</ >
66
69
)
Original file line number Diff line number Diff line change @@ -106,7 +106,9 @@ export const PostMetaBar: Component<{
106
106
{ ! ! meta . count ?. read && (
107
107
< div className = "flex min-w-0 items-center space-x-1" >
108
108
< i className = "icon-[mingcute--eye-2-line]" />
109
- < span className = "min-w-0 truncate" > { meta . count . read } </ span >
109
+ < span className = "min-w-0 truncate" >
110
+ < NumberSmoothTransition > { meta . count . read } </ NumberSmoothTransition >
111
+ </ span >
110
112
</ div >
111
113
) }
112
114
{ ! ! meta . count ?. like && (
Original file line number Diff line number Diff line change @@ -262,6 +262,34 @@ export const eventHandler = (
262
262
deleteActivityPresence ( payload . identity )
263
263
break
264
264
}
265
+ case EventTypes . ARTICLE_READ_COUNT_UPDATE : {
266
+ const { id, count, type } = data
267
+ if ( ! count ) {
268
+ break
269
+ }
270
+
271
+ switch ( type ) {
272
+ case 'post' : {
273
+ const currentData = getGlobalCurrentPostData ( )
274
+ if ( currentData ?. id === id ) {
275
+ setGlobalCurrentPostData ( ( draft ) => {
276
+ draft . count . read = count
277
+ } )
278
+ }
279
+ break
280
+ }
281
+ case 'note' : {
282
+ const currentData = getCurrentNoteData ( ) ?. data
283
+ if ( currentData ?. id === id ) {
284
+ setCurrentNoteData ( ( draft ) => {
285
+ draft . data . count . read = count
286
+ } )
287
+ }
288
+ break
289
+ }
290
+ }
291
+ break
292
+ }
265
293
266
294
case 'fn#media-update' : {
267
295
setActivityMediaInfo ( data )
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export const enum EventTypes {
32
32
33
33
ACTIVITY_UPDATE_PRESENCE = 'ACTIVITY_UPDATE_PRESENCE' ,
34
34
ACTIVITY_LEAVE_PRESENCE = 'ACTIVITY_LEAVE_PRESENCE' ,
35
+ ARTICLE_READ_COUNT_UPDATE = 'ARTICLE_READ_COUNT_UPDATE' ,
35
36
}
36
37
37
38
export interface EventTypesPayload {
You can’t perform that action at this time.
0 commit comments