@@ -45,7 +45,8 @@ export const useReactionHandler = <
4545 await channel . deleteReaction ( id , type ) ;
4646 }
4747 } catch ( error ) {
48- throw new Error ( 'toggle reaction failed' ) ;
48+ // revert to the original message if the API call fails
49+ if ( message ) updateMessage ( message ) ;
4950 }
5051 } , 1000 ) ;
5152
@@ -54,9 +55,8 @@ export const useReactionHandler = <
5455 event . preventDefault ( ) ;
5556 }
5657
57- if ( ! updateMessage || ! message || ! channel || ! client ) {
58- console . warn ( reactionHandlerWarning ) ;
59- return ;
58+ if ( ! message ) {
59+ return console . warn ( reactionHandlerWarning ) ;
6060 }
6161
6262 let userExistingReaction = ( null as unknown ) as ReactionResponse < Re , Us > ;
@@ -75,18 +75,14 @@ export const useReactionHandler = <
7575 } ) ;
7676 }
7777
78- // Make the API call in the background
79- // If it fails, revert to the old message...
8078 try {
8179 if ( userExistingReaction ) {
8280 await toggleReaction ( message . id , userExistingReaction . type , false ) ;
8381 } else {
84- // this.props.channel.state.addReaction(tmpReaction, this.props.message);
8582 await toggleReaction ( message . id , reactionType , true ) ;
8683 }
8784 } catch ( error ) {
88- // revert to the original message if the API call fails
89- updateMessage ( message ) ;
85+ console . log ( { error } ) ;
9086 }
9187 } ;
9288} ;
0 commit comments