File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -47,10 +47,12 @@ export class ExtraFieldTool extends BasicTool {
4747 * Replace extra field of an item.
4848 * @param item
4949 * @param fields
50+ * @param [save] Whether to save the item.
5051 */
5152 async replaceExtraFields (
5253 item : Zotero . Item ,
5354 fields : Map < string , string > ,
55+ save = true ,
5456 ) : Promise < void > {
5557 const kvs : string [ ] = [ ] ;
5658 if ( fields . has ( "__nonStandard__" ) ) {
@@ -61,26 +63,28 @@ export class ExtraFieldTool extends BasicTool {
6163 kvs . push ( `${ k } : ${ v } ` ) ;
6264 } ) ;
6365 item . setField ( "extra" , kvs . join ( "\n" ) ) ;
64- await item . saveTx ( ) ;
66+ if ( save ) await item . saveTx ( ) ;
6567 }
6668
6769 /**
6870 * Set an key-value pair to the item's extra field
6971 * @param item
7072 * @param key
7173 * @param value
74+ * @param [save] Whether to save the item.
7275 */
7376 async setExtraField (
7477 item : Zotero . Item ,
7578 key : string ,
7679 value : string ,
80+ save = true ,
7781 ) : Promise < void > {
7882 const fields = this . getExtraFields ( item ) ;
7983 if ( value === "" || typeof value === "undefined" ) {
8084 fields . delete ( key ) ;
8185 } else {
8286 fields . set ( key , value ) ;
8387 }
84- await this . replaceExtraFields ( item , fields ) ;
88+ await this . replaceExtraFields ( item , fields , save ) ;
8589 }
8690}
You can’t perform that action at this time.
0 commit comments