• Robert Knight's avatar
    Memoize `Annotation` and `Thread` components · a5f1b9f8
    Robert Knight authored
    Typing in replies in large threads (eg. those that already have hundres
    of replies) was slow because every keystroke would cause every
    reply to be re-rendered. The critical thread list virtualization
    optimization in the client only applies to top-level threads and doesn't
    benefit the case of a single thread with a large number of replies.
    
    Implement some easy performance optimizations for large threads (ie.
    with hundreds of replies) by memoizing:
    
     1) `Thread` components so that they don't re-render if something
        changes in a parent but the thread itself is unchanged.
     2) `Annotation` components so that they don't re-render if something
        changes elsewhere in the thread list but the current annotation is not
        changed.
    
    As a result, creating and editing replies in large threads is faster. The
    initial action to show a large thread list by clicking "Show replies" is still
    slow because this change doesn't help the initial render. However,
    editing performance is the most important issue from a user's
    perspective.
    
    Partial fix for #2897
    a5f1b9f8
thread.js 4.18 KB