From 4142f4b316a1be1c16d88b68c1263f831af0bfd4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 25 Aug 2020 14:22:23 -0400 Subject: [PATCH] Replace occurrences of `.getNote()` with `.note` --- .../content/zotero/bindings/attachmentbox.xml | 2 +- chrome/content/zotero/bindings/noteeditor.xml | 6 ++-- .../zotero/containers/noteEditorContainer.js | 2 +- chrome/content/zotero/xpcom/data/item.js | 4 +-- chrome/content/zotero/xpcom/data/notes.js | 2 +- chrome/content/zotero/xpcom/itemTreeView.js | 2 +- chrome/content/zotero/xpcom/quickCopy.js | 2 +- chrome/content/zotero/zoteroPane.js | 2 +- test/tests/attachmentsTest.js | 2 +- test/tests/dataObjectTest.js | 6 ++-- test/tests/syncEngineTest.js | 10 +++--- test/tests/translateTest.js | 32 +++++++++---------- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/chrome/content/zotero/bindings/attachmentbox.xml b/chrome/content/zotero/bindings/attachmentbox.xml index 4604c9567a..9e0f6eb7c5 100644 --- a/chrome/content/zotero/bindings/attachmentbox.xml +++ b/chrome/content/zotero/bindings/attachmentbox.xml @@ -362,7 +362,7 @@ // Note editor var noteEditor = this._id('attachment-note-editor'); - if (this.displayNote && (this.displayNoteIfEmpty || this.item.getNote() != '')) { + if (this.displayNote && (this.displayNoteIfEmpty || this.item.note != '')) { noteEditor.linksOnTop = true; noteEditor.hidden = false; diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml index efc309c138..cb607a530b 100644 --- a/chrome/content/zotero/bindings/noteeditor.xml +++ b/chrome/content/zotero/bindings/noteeditor.xml @@ -101,12 +101,12 @@ } } else { - let curValue = this.item.getNote(); + let curValue = this.item.note; if (curValue !== this._lastHtmlValue) { this.initEditor(); } } - this._lastHtmlValue = this.item.getNote(); + this._lastHtmlValue = this.item.note; } this._id('links-container').hidden = !(this.displayTags && this.displayRelated); @@ -192,7 +192,7 @@ if (!val) this._item = null; if (this._item && this._item.id === val.id) return; - this._lastHtmlValue = val.getNote(); + this._lastHtmlValue = val.note; this._editor = new Zotero.NoteEditor(); this._editor.init({ diff --git a/chrome/content/zotero/containers/noteEditorContainer.js b/chrome/content/zotero/containers/noteEditorContainer.js index 6411442214..967c28c48e 100644 --- a/chrome/content/zotero/containers/noteEditorContainer.js +++ b/chrome/content/zotero/containers/noteEditorContainer.js @@ -31,7 +31,7 @@ class NoteEditor { this.window.addEventListener('message', this.listener); this.quickFormatWindow = null; - let data = this.state ? { state: this.state } : { html: this.item.getNote() }; + let data = this.state ? { state: this.state } : { html: this.item.note }; this.postMessage({ op: 'init', ...data, libraryId: this.item.libraryID, diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index cd8a89429c..c75585031e 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2019,7 +2019,7 @@ Zotero.Item.prototype.numNotes = function(includeTrashed, includeEmbedded) { if (includeEmbedded) { // Include embedded attachment notes that aren't empty num += Zotero.Items.get(this.getAttachments(includeTrashed)) - .filter(x => x.getNote() !== '').length; + .filter(x => x.note !== '').length; } return num; } @@ -2073,7 +2073,7 @@ Zotero.Item.prototype.hasNote = Zotero.Promise.coroutine(function* () { Zotero.defineProperty(Zotero.Item.prototype, 'note', { get: function () { if (!this.isNote() && !this.isAttachment()) { - throw new Error("getNote() can only be called on notes and attachments " + throw new Error(".note can only be accessed on notes and attachments " + `(${this.libraryID}/${this.key} is a ${Zotero.ItemTypes.getName(this.itemTypeID)})`); } diff --git a/chrome/content/zotero/xpcom/data/notes.js b/chrome/content/zotero/xpcom/data/notes.js index 163a56aff8..993ad60a3e 100644 --- a/chrome/content/zotero/xpcom/data/notes.js +++ b/chrome/content/zotero/xpcom/data/notes.js @@ -80,7 +80,7 @@ Zotero.Notes = new function() { * @returns {Promise} */ this.updateURIs = async (item) => { - let html = item.getNote(); + let html = item.note; let num = 0; // "uri":"http://zotero.org/users/local/(.+?)/items/(.+?)" let regex = new RegExp(/%22uri%22%3A%22http%3A%2F%2Fzotero.org%2Fusers%2Flocal%2F(.+?)%2Fitems%2F(.+?)%22/g); diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index ed55b0a8b5..d8d12c7c13 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -3509,7 +3509,7 @@ Zotero.ItemTreeRow.prototype.numNotes = function() { return 0; } if (this.ref.isAttachment()) { - return this.ref.getNote() !== '' ? 1 : 0; + return this.ref.note !== '' ? 1 : 0; } return this.ref.numNotes(false, true) || 0; } diff --git a/chrome/content/zotero/xpcom/quickCopy.js b/chrome/content/zotero/xpcom/quickCopy.js index 647a029810..c7a7921307 100644 --- a/chrome/content/zotero/xpcom/quickCopy.js +++ b/chrome/content/zotero/xpcom/quickCopy.js @@ -292,7 +292,7 @@ Zotero.QuickCopy = new function() { div.className = "zotero-note"; // AMO reviewer: This documented is never rendered (and the inserted markup // is sanitized anyway) - div.insertAdjacentHTML('afterbegin', notes[i].getNote()); + div.insertAdjacentHTML('afterbegin', notes[i].note); container.appendChild(div); textContainer.appendChild(textDoc.importNode(div, true)); } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 3303ebfa92..94601e2112 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -3490,7 +3490,7 @@ var ZoteroPane = new function() var items = this.getSelectedItems(); if (this.itemsView.selection.count == 1 && items[0] && items[0].isNote()) { - var note = items[0].getNote() + var note = items[0].note; items[0].setNote(note + text); yield items[0].saveTx(); diff --git a/test/tests/attachmentsTest.js b/test/tests/attachmentsTest.js index 23a431665a..1bcfc60012 100644 --- a/test/tests/attachmentsTest.js +++ b/test/tests/attachmentsTest.js @@ -1327,7 +1327,7 @@ describe("Zotero.Attachments", function() { assert.equal(newAttachment.attachmentContentType, 'application/pdf'); assert.isTrue(await newAttachment.fileExists()); assert.equal(newAttachment.getField('title'), 'Title'); - assert.equal(newAttachment.getNote(), 'Note'); + assert.equal(newAttachment.note, 'Note'); assert.sameDeepMembers(newAttachment.getTags(), [{ tag: 'Tag' }]); assert.sameMembers(newAttachment.relatedItems, [relatedItem.key]); assert.sameMembers(relatedItem.relatedItems, [newAttachment.key]); diff --git a/test/tests/dataObjectTest.js b/test/tests/dataObjectTest.js index bf5f63445b..f9a8a3beff 100644 --- a/test/tests/dataObjectTest.js +++ b/test/tests/dataObjectTest.js @@ -227,21 +227,21 @@ describe("Zotero.DataObject", function() { var item = new Zotero.Item('book'); var id = yield item.saveTx(); yield item.loadAllData(); - assert.throws(item.getNote.bind(item), 'getNote() can only be called on notes and attachments'); + assert.throws(item.getNote.bind(item), 'note can only be called on notes and attachments'); }) it("should load data on an attachment item", function* () { var item = new Zotero.Item('attachment'); var id = yield item.saveTx(); yield item.loadAllData(); - assert.equal(item.getNote(), ''); + assert.equal(item.note, ''); }) it("should load data on a note item", function* () { var item = new Zotero.Item('note'); var id = yield item.saveTx(); yield item.loadAllData(); - assert.equal(item.getNote(), ''); + assert.equal(item.note, ''); }) }) diff --git a/test/tests/syncEngineTest.js b/test/tests/syncEngineTest.js index 19d60bc846..678e11a369 100644 --- a/test/tests/syncEngineTest.js +++ b/test/tests/syncEngineTest.js @@ -339,7 +339,7 @@ describe("Zotero.Sync.Data.Engine", function () { yield assertInCache(obj); obj = yield Zotero.Items.getByLibraryAndKeyAsync(userLibraryID, "BBBBBBBB"); - assert.equal(obj.getNote(), 'This is a note.'); + assert.equal(obj.note, 'This is a note.'); assert.equal(obj.parentItemID, parentItemID); assert.equal(obj.version, 3); assert.isTrue(obj.synced); @@ -513,7 +513,7 @@ describe("Zotero.Sync.Data.Engine", function () { yield assertInCache(obj); obj = Zotero.Items.getByLibraryAndKey(libraryID, "BBBBBBBB"); - assert.equal(obj.getNote(), 'This is a note.'); + assert.equal(obj.note, 'This is a note.'); assert.equal(obj.parentItemID, parentItemID); assert.equal(obj.version, 3); assert.isTrue(obj.synced); @@ -3487,7 +3487,7 @@ describe("Zotero.Sync.Data.Engine", function () { await obj.saveTx({ skipDateModifiedUpdate: true }); - values[i].left.note = obj.getNote(); + values[i].left.note = obj.note; values[i].left.version = obj.getField('version'); } @@ -3529,8 +3529,8 @@ describe("Zotero.Sync.Data.Engine", function () { await engine._downloadObjects('item', objects.map(o => o.key)); await crPromise; - assert.equal(objects[0].getNote(), values[0].right.note); - assert.equal(objects[1].getNote(), values[1].left.note); + assert.equal(objects[0].note, values[0].right.note); + assert.equal(objects[1].note, values[1].left.note); assert.equal(objects[0].version, values[0].right.version); assert.equal(objects[1].version, values[1].right.version); assert.isTrue(objects[0].synced); diff --git a/test/tests/translateTest.js b/test/tests/translateTest.js index 6ee924da05..521509f5fb 100644 --- a/test/tests/translateTest.js +++ b/test/tests/translateTest.js @@ -213,13 +213,13 @@ describe("Zotero.Translate", function() { let noteIDs = newItems["Test Item"].getNotes(); let note1 = yield Zotero.Items.getAsync(noteIDs[0]); assert.equal(Zotero.ItemTypes.getName(note1.itemTypeID), "note"); - assert.equal(note1.getNote(), "1 note as string"); + assert.equal(note1.note, "1 note as string"); let note2 = yield Zotero.Items.getAsync(noteIDs[1]); assert.equal(Zotero.ItemTypes.getName(note2.itemTypeID), "note"); - assert.equal(note2.getNote(), "2 note as object"); + assert.equal(note2.note, "2 note as object"); checkTestTags(note2); let note3 = newItems["standalone note"]; - assert.equal(note3.getNote(), "standalone note"); + assert.equal(note3.note, "standalone note"); checkTestTags(note3); }); @@ -323,20 +323,20 @@ describe("Zotero.Translate", function() { for (let savedAttachments of [[newItems["Empty PDF"], newItems["Link to zotero.org"]], [containedAttachments[0], containedAttachments[1]]]) { assert.equal(savedAttachments[0].getField("title"), "Empty PDF"); - assert.equal(savedAttachments[0].getNote(), "attachment note"); + assert.equal(savedAttachments[0].note, "attachment note"); assert.equal(savedAttachments[0].attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_FILE); checkTestTags(savedAttachments[0]); assert.equal(savedAttachments[1].getField("title"), "Link to zotero.org"); assert.equal(savedAttachments[1].getField("url"), "http://www.zotero.org/"); - assert.equal(savedAttachments[1].getNote(), "attachment 2 note"); + assert.equal(savedAttachments[1].note, "attachment 2 note"); assert.equal(savedAttachments[1].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL); checkTestTags(savedAttachments[1]); } assert.equal(containedAttachments[2].getField("title"), "Snapshot"); assert.equal(containedAttachments[2].getField("url"), "http://www.example.com/"); - assert.equal(containedAttachments[2].getNote(), "attachment 3 note"); + assert.equal(containedAttachments[2].note, "attachment 3 note"); assert.equal(containedAttachments[2].attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); checkTestTags(containedAttachments[2]); }); @@ -371,7 +371,7 @@ describe("Zotero.Translate", function() { assert.equal(containedAttachments[0].getField("title"), "Snapshot with missing file"); assert.equal(containedAttachments[0].getField("url"), "http://www.example.com/"); - assert.equal(containedAttachments[0].getNote(), "attachment note"); + assert.equal(containedAttachments[0].note, "attachment note"); assert.equal(containedAttachments[0].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL); checkTestTags(containedAttachments[0]); }); @@ -548,7 +548,7 @@ describe("Zotero.Translate", function() { assert.equal(attachments[1].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_FILE); assert.equal(attachments[1].attachmentContentType, 'text/html'); assert.equal(attachments[1].attachmentCharset, 'utf-8'); - assert.equal(attachments[1].getNote(), file2URL); + assert.equal(attachments[1].note, file2URL); }); it("import translators shouldn't save linked-file attachment with linkFiles: true if path is within current storage directory", async function () { @@ -648,20 +648,20 @@ describe("Zotero.Translate", function() { let link = containedAttachments["Link to zotero.org"]; assert.equal(link.getField("url"), "http://www.zotero.org/"); - assert.equal(link.getNote(), "attachment note"); + assert.equal(link.note, "attachment note"); assert.equal(link.attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL); checkTestTags(link, true); let snapshot = containedAttachments["Test Snapshot"]; assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html"); - assert.equal(snapshot.getNote(), "attachment 2 note"); + assert.equal(snapshot.note, "attachment 2 note"); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentContentType, "text/html"); checkTestTags(snapshot, true); let pdf = containedAttachments["Test PDF"]; assert.equal(pdf.getField("url"), "http://127.0.0.1:23119/test/translate/test.pdf"); - assert.equal(pdf.getNote(), "attachment 3 note"); + assert.equal(pdf.note, "attachment 3 note"); assert.equal(pdf.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(pdf.attachmentContentType, "application/pdf"); checkTestTags(pdf, true); @@ -700,7 +700,7 @@ describe("Zotero.Translate", function() { let snapshot = containedAttachments[0]; assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html"); - assert.equal(snapshot.getNote(), "attachment note"); + assert.equal(snapshot.note, "attachment note"); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentContentType, "text/html"); checkTestTags(snapshot, true); @@ -734,7 +734,7 @@ describe("Zotero.Translate", function() { let snapshot = containedAttachments[0]; assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html"); - assert.equal(snapshot.getNote(), "attachment note"); + assert.equal(snapshot.note, "attachment note"); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentContentType, "text/html"); checkTestTags(snapshot, true); @@ -798,7 +798,7 @@ describe("Zotero.Translate", function() { let pdf = containedAttachments[0]; assert.equal(pdf.getField("title"), "Test PDF"); assert.equal(pdf.getField("url"), "http://127.0.0.1:23119/test/translate/test.pdf"); - assert.equal(pdf.getNote(), "attachment note"); + assert.equal(pdf.note, "attachment note"); assert.equal(pdf.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); checkTestTags(pdf, true); }); @@ -901,7 +901,7 @@ describe("Zotero.Translate", function() { var snapshot = containedAttachments[0]; assert.equal(snapshot.getField("url"), url + '?t'); - assert.equal(snapshot.getNote(), "attachment note"); + assert.equal(snapshot.note, "attachment note"); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentContentType, "text/html"); checkTestTags(snapshot, true); @@ -951,7 +951,7 @@ describe("Zotero.Translate", function() { var snapshot = containedAttachments[0]; assert.equal(snapshot.getField("url"), url); - assert.equal(snapshot.getNote(), "attachment note"); + assert.equal(snapshot.note, "attachment note"); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentContentType, "text/html"); checkTestTags(snapshot, true);