react-tweet icon indicating copy to clipboard operation
react-tweet copied to clipboard

Add support for displaying threads

Open sudarshang opened this issue 8 years ago • 4 comments

The twitter api does not directly support threads. We can still infer the start, end, and membership of a thread from the in_reply_to_status_id field. While displaying tweets it might be beneficial to indicate that they are part of a thread.

Here is how I would like to implement this:-

To mimic's Twitter desktops implementation of thread display we would need to add a pseudo div after the user avatar for adding a bar. The tweet data will have following boolean fields isThreadStart, isThreadMember and isThreadEnd

sudarshang avatar Mar 20 '18 19:03 sudarshang

im ok with this but can we leave these props out of data? Dont want to muddle the actual twitter data with additional styling information.

mannynotfound avatar Mar 20 '18 22:03 mannynotfound

To implement threads I need to reorder the tweets data as provided by the home_timeline api because the tweets in the thread need to be contiguous. Once they are thus reordered it is simpler to stick the information about thread membership on the tweet data than to maintain an auxiliary data structure for the thread membership. If you have any thoughts on how to do this without muddling the twitter data please do let me know.

sudarshang avatar Mar 21 '18 02:03 sudarshang

@sudarshang thats fine but I dont think you would need to do it in the data prop of the Tweet component. It may be that this is a high order component called TweetThread that does this logic for you but essentially some code that ends up like:

myOrderedTweets.map((tweet, idx, arr) => (
  <Tweet data={tweet} isThreadStart={idx === 0} isThreadMember={idx > 0  && idx < arr.length -1}
    isThreadEnd={idx === arr.length -1} />
))

mannynotfound avatar Mar 21 '18 15:03 mannynotfound

Got you! Thanks for your suggestion.

sudarshang avatar Mar 21 '18 20:03 sudarshang