From 73fb9c13dfe08115313237be4d34b3ad1cbdccda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Thu, 2 Dec 2021 12:40:48 +0200 Subject: [PATCH] Fix preference style list refresh on modification. Closes #2256 --- .../zotero/preferences/preferences_cite.jsx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_cite.jsx b/chrome/content/zotero/preferences/preferences_cite.jsx index bf07acbf89..16f358c914 100644 --- a/chrome/content/zotero/preferences/preferences_cite.jsx +++ b/chrome/content/zotero/preferences/preferences_cite.jsx @@ -34,6 +34,7 @@ var { IntlProvider } = require('react-intl'); var { makeRowRenderer } = VirtualizedTable; Zotero_Preferences.Cite = { + styles: [], wordPluginIDs: new Set([ 'zoteroOpenOfficeIntegration@zotero.org', 'zoteroMacWordIntegration@zotero.org', @@ -88,6 +89,13 @@ Zotero_Preferences.Cite = { Zotero.debug("Refreshing styles list"); await Zotero.Styles.init(); + this.styles = Zotero.Styles.getVisible() + .map((style) => { + return { + title: style.title, + updated: Zotero.Date.sqlToDate(style.updated, true).toLocaleDateString() + }; + }); if (!this._tree) { const columns = [ @@ -108,20 +116,13 @@ Zotero_Preferences.Cite = { return false; } }; - let styles = Zotero.Styles.getVisible() - .map((style) => { - return { - title: style.title, - updated: Zotero.Date.sqlToDate(style.updated, true).toLocaleDateString() - }; - }); let elem = ( styles.length} + getRowCount={() => this.styles.length} id="styleManager-table" ref={ref => this._tree = ref} - renderItem={makeRowRenderer(index => styles[index])} + renderItem={makeRowRenderer(index => this.styles[index])} showHeader={true} multiSelect={true} columns={columns} @@ -129,7 +130,7 @@ Zotero_Preferences.Cite = { disableFontSizeScaling={true} onSelectionChange={() => document.getElementById('styleManager-delete').disabled = undefined} onKeyDown={handleKeyDown} - getRowString={index => styles[index].title} + getRowString={index => this.styles[index].title} /> );