File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -225,6 +225,20 @@ $(() => {
225225 } ) ;
226226 } ) ;
227227
228+ $ ( document ) . on ( 'click' , '.js-follow-thread' , async ( ev ) => {
229+ ev . preventDefault ( ) ;
230+
231+ const $tgt = $ ( ev . target ) ;
232+ const threadID = $tgt . data ( "thread" ) ;
233+
234+ const data = await QPixel . followThread ( threadID ) ;
235+
236+ QPixel . handleJSONResponse ( data , ( ) => {
237+ const wrapper = getCommentThreadWrapper ( $tgt ) ;
238+ openThread ( wrapper , threadID ) ;
239+ } ) ;
240+ } ) ;
241+
228242 $ ( document ) . on ( 'click' , '.js-lock-thread' , async ( ev ) => {
229243 ev . preventDefault ( ) ;
230244
Original file line number Diff line number Diff line change @@ -467,6 +467,14 @@ window.QPixel = {
467467 return QPixel . parseJSONResponse ( resp , 'Failed to delete thread' ) ;
468468 } ,
469469
470+ followThread : async ( id ) => {
471+ const resp = await QPixel . fetchJSON ( `/comments/thread/${ id } /follow` , { } , {
472+ headers : { 'Accept' : 'application/json' } ,
473+ } ) ;
474+
475+ return QPixel . parseJSONResponse ( resp , 'Failed to follow thread' ) ;
476+ } ,
477+
470478 lockThread : async ( id , duration ) => {
471479 const resp = await QPixel . fetchJSON ( `/comments/thread/${ id } /lock` , {
472480 duration,
Original file line number Diff line number Diff line change 1818 </ a >
1919<% else %>
2020 < a href ="# "
21- class ="widget--header-link js--restrict-thread "
22- data-action ="follow "
21+ class ="widget--header-link js-follow-thread "
2322 data-thread ="<%= thread . id %> "
2423 title ="Follow this thread to be notified of every response. "
2524 role ="button "
Original file line number Diff line number Diff line change @@ -561,6 +561,13 @@ interface QPixel {
561561 */
562562 deleteThread ?: ( id : string ) => Promise < QPixelResponseJSON >
563563
564+ /**
565+ * Attempts to follow a comment thread
566+ * @param id id of the thread to follow
567+ * @returns result of the operation
568+ */
569+ followThread ?: ( id : string ) => Promise < QPixelResponseJSON >
570+
564571 /**
565572 * Attempts to start following comments on a given post
566573 * @param postId id of the post to follow comments on
You can’t perform that action at this time.
0 commit comments