From 45fd754fd38307b18f2810f8fe944b72927dd6b7 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 23 Jul 2015 14:30:32 -0700 Subject: [PATCH] fix(thread-list): Cache `MailLabel` component instances to prevent needless rendering --- internal_packages/thread-list/lib/thread-list.cjsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal_packages/thread-list/lib/thread-list.cjsx b/internal_packages/thread-list/lib/thread-list.cjsx index 04acf8c3e..47c5c59a7 100644 --- a/internal_packages/thread-list/lib/thread-list.cjsx +++ b/internal_packages/thread-list/lib/thread-list.cjsx @@ -79,6 +79,8 @@ class ThreadList extends React.Component else + c3LabelComponentCache = {} + c3 = new ListTabular.Column name: "Message" flex: 4 @@ -92,9 +94,12 @@ class ThreadList extends React.Component currentCategoryId = FocusedCategoryStore.categoryId() allCategoryId = CategoryStore.getStandardCategory('all')?.id ignoredIds = [currentCategoryId, allCategoryId] + for label in (thread.sortedLabels() ? []) continue if label.id in ignoredIds - labels.push + if not c3LabelComponentCache[label.id] + c3LabelComponentCache[label.id] = + labels.push c3LabelComponentCache[label.id] {labels}