Extra columns in extensions.zotero.pane.persist cause every column in the reference list to be selected

42 views
Skip to first unread message

Emiliano Heyns

unread,
Sep 18, 2017, 1:57:55 PM9/18/17
to zotero-dev
I'm adding an extra column to zotero-items-columns-header to display BBTs citekey in an overlay:

  <treecols id="zotero-items-columns-header">
    <treecol
      id="zotero-items-column-citekey" primary="true"
      label="Citekey"
      flex="1"
      insertafter="zotero-items-column-title"
      zotero-persist="width ordinal hidden sortActive sortDirection"
    />
  </treecols>

this works nicely, but when BBT is uninstalled, the data remains persisted in extensions.zotero.pane.persist as the column is still available at shutdown, so Zotero.serializePersist will store it. The problem I have is at startup after uninstall, all columns in the reference list are selected, and I have no idea why. During uninstall (an event that happens well before shutdown) I remove the "persist" attribute from that column so that Zotero.serializePersist will not see it.

The weird thing is that a) I can't see Zotero.serializePersist being called (I've wrapped it in a monkey-patch for the occasion so I can see if it's being called), and b) looking at the code of Zotero.unserializePersist it skips any columns it cannot find a corresponding element for, so even if I didn't strip the value, it should just ignore it, and c) even though I can't see Zotero.serializePersist being called, I can see that extensions.zotero.pane.persist is set at shutdown *including* zotero-items-column-citekey through a prefs observer I have set.

I really want to leave Zotero in a clean state when BBT is installed, but I can't seem to get this bit right. It's reproducible by just putting 

user_pref("extensions.zotero.pane.persist", '{"zotero-collections-pane":{},"zotero-tags-splitter":{},"zotero-tag-selector":{"height":"0"},"zotero-collections-splitter":{},"zotero-layout-switcher":{"orient":"horizontal"},"zotero-items-pane":{},"zotero-items-tree":{"current-view-group":"default"},"zotero-items-column-title":{"ordinal":"1","hidden":"false"},"zotero-items-column-firstCreator":{"ordinal":"3","hidden":"false"},"zotero-items-column-itemType":{"width":"40","ordinal":"5","hidden":"true"},"zotero-items-column-date":{"ordinal":"7","hidden":"true"},"zotero-items-column-year":{"ordinal":"9","hidden":"true"},"zotero-items-column-publisher":{"ordinal":"11","hidden":"true"},"zotero-items-column-publicationTitle":{"ordinal":"13","hidden":"true"},"zotero-items-column-journalAbbreviation":{"ordinal":"15","hidden":"true"},"zotero-items-column-language":{"ordinal":"17","hidden":"true"},"zotero-items-column-accessDate":{"ordinal":"19","hidden":"true"},"zotero-items-column-libraryCatalog":{"ordinal":"21","hidden":"true"},"zotero-items-column-callNumber":{"ordinal":"23","hidden":"true"},"zotero-items-column-rights":{"ordinal":"25","hidden":"true"},"zotero-items-column-dateAdded":{"ordinal":"27","hidden":"true"},"zotero-items-column-dateModified":{"ordinal":"29","hidden":"true"},"zotero-items-column-archive":{"ordinal":"31","hidden":"true"},"zotero-items-column-archiveLocation":{"ordinal":"33","hidden":"true"},"zotero-items-column-place":{"ordinal":"35","hidden":"true"},"zotero-items-column-volume":{"ordinal":"37","hidden":"true"},"zotero-items-column-edition":{"ordinal":"39","hidden":"true"},"zotero-items-column-pages":{"ordinal":"41","hidden":"true"},"zotero-items-column-issue":{"ordinal":"43","hidden":"true"},"zotero-items-column-series":{"ordinal":"45","hidden":"true"},"zotero-items-column-seriesTitle":{"ordinal":"47","hidden":"true"},"zotero-items-column-court":{"ordinal":"49","hidden":"true"},"zotero-items-column-medium":{"ordinal":"51","hidden":"true"},"zotero-items-column-genre":{"ordinal":"53","hidden":"true"},"zotero-items-column-system":{"ordinal":"55","hidden":"true"},"zotero-items-column-extra":{"ordinal":"57","hidden":"true"},"zotero-items-column-hasAttachment":{"ordinal":"59","hidden":"false"},"zotero-items-column-numNotes":{"ordinal":"61","hidden":"true"},"zotero-items-splitter":{"orient":"horizontal"},"zotero-item-pane":{}}');

in prefs.js before start when BBT is not installed.

 

Dan Stillman

unread,
Sep 21, 2017, 3:23:47 AM9/21/17
to zoter...@googlegroups.com
On 9/18/17 1:57 PM, Emiliano Heyns wrote:
> I'm adding an extra column to zotero-items-columns-header to display
> BBTs citekey in an overlay:
>
>   <treecols id="zotero-items-columns-header">
>     <treecol
>       id="zotero-items-column-citekey" primary="true"
>       label="Citekey"
>       flex="1"
>       insertafter="zotero-items-column-title"
>       zotero-persist="width ordinal hidden sortActive sortDirection"
>     />
>   </treecols>
>
> this works nicely, but when BBT is uninstalled, the data remains
> persisted in extensions.zotero.pane.persist as the column is still
> available at shutdown, so Zotero.serializePersist will store it. The
> problem I have is at startup after uninstall, all columns in the
> reference list are selected, and I have no idea why.

I'm a bit confused here.

Do you mean that all columns are unselected (rather than selected)?
That's what I see when I paste in that user_pref line, and Zotero uses
its default sort order.

What data are you saying is being persisted? The
zotero-items-column-citekey column doesn't show in the sample user_pref
line that you gave.

What problem am I reproducing by pasting in that user_pref line?

Emiliano Heyns

unread,
Sep 21, 2017, 3:43:30 AM9/21/17
to zotero-dev


On Thursday, September 21, 2017 at 9:23:47 AM UTC+2, Dan Stillman wrote:
On 9/18/17 1:57 PM, Emiliano Heyns wrote:
> I'm adding an extra column to zotero-items-columns-header to display
> BBTs citekey in an overlay:
>
>   <treecols id="zotero-items-columns-header">
>     <treecol
>       id="zotero-items-column-citekey" primary="true"
>       label="Citekey"
>       flex="1"
>       insertafter="zotero-items-column-title"
>       zotero-persist="width ordinal hidden sortActive sortDirection"
>     />
>   </treecols>
>
> this works nicely, but when BBT is uninstalled, the data remains
> persisted in extensions.zotero.pane.persist as the column is still
> available at shutdown, so Zotero.serializePersist will store it. The
> problem I have is at startup after uninstall, all columns in the
> reference list are selected, and I have no idea why.

I'm a bit confused here.

Yeah I messed up a few things. For starters, the user_pref line above is wrong, it should have been

user_pref("extensions.zotero.pane.persist", "{\"zotero-collections-pane\":{},\"zotero-tags-splitter\":{},\"zotero-tag-selector\":{\"height\":\"0\"},\"zotero-collections-splitter\":{},\"zotero-layout-switcher\":{\"orient\":\"horizontal\"},\"zotero-items-pane\":{},\"zotero-items-tree\":{\"current-view-group\":\"default\"},\"zotero-items-column-title\":{\"ordinal\":\"1\",\"hidden\":\"false\"},\"zotero-items-column-citekey\":{\"ordinal\":\"63\"},\"zotero-items-column-firstCreator\":{\"ordinal\":\"3\",\"hidden\":\"false\"},\"zotero-items-column-itemType\":{\"width\":\"40\",\"ordinal\":\"5\",\"hidden\":\"true\"},\"zotero-items-column-date\":{\"ordinal\":\"7\",\"hidden\":\"true\"},\"zotero-items-column-year\":{\"ordinal\":\"9\",\"hidden\":\"true\"},\"zotero-items-column-publisher\":{\"ordinal\":\"11\",\"hidden\":\"true\"},\"zotero-items-column-publicationTitle\":{\"ordinal\":\"13\",\"hidden\":\"true\"},\"zotero-items-column-journalAbbreviation\":{\"ordinal\":\"15\",\"hidden\":\"true\"},\"zotero-items-column-language\":{\"ordinal\":\"17\",\"hidden\":\"true\"},\"zotero-items-column-accessDate\":{\"ordinal\":\"19\",\"hidden\":\"true\"},\"zotero-items-column-libraryCatalog\":{\"ordinal\":\"21\",\"hidden\":\"true\"},\"zotero-items-column-callNumber\":{\"ordinal\":\"23\",\"hidden\":\"true\"},\"zotero-items-column-rights\":{\"ordinal\":\"25\",\"hidden\":\"true\"},\"zotero-items-column-dateAdded\":{\"ordinal\":\"27\",\"hidden\":\"true\"},\"zotero-items-column-dateModified\":{\"ordinal\":\"29\",\"hidden\":\"true\"},\"zotero-items-column-archive\":{\"ordinal\":\"31\",\"hidden\":\"true\"},\"zotero-items-column-archiveLocation\":{\"ordinal\":\"33\",\"hidden\":\"true\"},\"zotero-items-column-place\":{\"ordinal\":\"35\",\"hidden\":\"true\"},\"zotero-items-column-volume\":{\"ordinal\":\"37\",\"hidden\":\"true\"},\"zotero-items-column-edition\":{\"ordinal\":\"39\",\"hidden\":\"true\"},\"zotero-items-column-pages\":{\"ordinal\":\"41\",\"hidden\":\"true\"},\"zotero-items-column-issue\":{\"ordinal\":\"43\",\"hidden\":\"true\"},\"zotero-items-column-series\":{\"ordinal\":\"45\",\"hidden\":\"true\"},\"zotero-items-column-seriesTitle\":{\"ordinal\":\"47\",\"hidden\":\"true\"},\"zotero-items-column-court\":{\"ordinal\":\"49\",\"hidden\":\"true\"},\"zotero-items-column-medium\":{\"ordinal\":\"51\",\"hidden\":\"true\"},\"zotero-items-column-genre\":{\"ordinal\":\"53\",\"hidden\":\"true\"},\"zotero-items-column-system\":{\"ordinal\":\"55\",\"hidden\":\"true\"},\"zotero-items-column-extra\":{\"ordinal\":\"57\",\"hidden\":\"true\"},\"zotero-items-column-hasAttachment\":{\"ordinal\":\"59\",\"hidden\":\"false\"},\"zotero-items-column-numNotes\":{\"ordinal\":\"61\",\"hidden\":\"true\"},\"zotero-items-splitter\":{\"orient\":\"horizontal\"},\"zotero-item-pane\":{}}");
 
Do you mean that all columns are unselected (rather than selected)?

No, I really do mean all are selected. If I click the column-select widget at the top-right of the reference list, all columns are selected. With the new user_pref line above I have it reproducible; shut down Zotero, edit prefs.js to replace the existing extensions.zotero.pane.persist with the one above (which adds the zotero-items-column-citekey data), and then start Zotero.
 
What data are you saying is being persisted? The
zotero-items-column-citekey column doesn't show in the sample user_pref
line that you gave.

What problem am I reproducing by pasting in that user_pref line?

That all columns are selected at start. My bad on pasting the wrong user_pref line; the new one should do it.

I've managed to work around it by monkey-patching serializePersist to strip  zotero-items-column-citekey if BBT has been removed or disabled, but I am looking to minimize the number of monkey patches. 
Reply all
Reply to author
Forward
0 new messages