Hello,
I’m working on adding notebook icons to the Desktop version of Joplin.
I’m around 90% done and have two problems.
I’m trying to add a new column to the folders table in the database. I’ve seen the guide written in the comments in joplin-database.js
- Add the new version number to the existingDatabaseVersions array
- Add the upgrade logic to the “switch (targetVersion)” statement below
I added the 29 to the existingDatabaseVersions array and I added the following switch code
if (targetVersion == 29) {
queries.push('ALTER TABLE folders ADD COLUMN `icon` TEXT NOT NULL DEFAULT ""');
}
Then I remove the current database and open ran the electron client.
However, when I do this, it resets the lib/joplin-database file. I’m guessing this has something to do with the build script.
The next problem I’m facing is Saving the icon.
I can successfully load the icon from the database. I added an icon column table manually to the folder table for testing purposes.
My code saves the title perfectly, but the icon isn’t getting saved. I tried to force an error by making the database busy, and I saw that the icon attribute isn’t even being loaded into the query (The title works fine).
This is the query that is logged when I force the Database is busy error.
UPDATE `folders` SET `title`=? WHERE `id`=?
I added functionality to add ‘fa-icon’ when a notebook is created.
folder = await Folder.save({ title: answer, icon: 'fa-book' }, { userSideValidation: true });
When I log the folder, I get
{title: "Maths", icon: "fa-book", id: "60be2a2a0cd44623a83821b36ffea247", updated_time: 1582915986458, created_time: 1582915986458, …}
But what happens is it instantly switches back to its previous state. Same with saving the icon. The icon gets shows for a moment, and then it disappears. I’m guessing this is because the item isn’t getting saved in the database. (Even though I get the response correctly)
Here is a screen capture of what happens.
The full code can be found here. https://github.com/rabeehrz/joplin/tree/issue-2268
If you could tell me how to do this properly, it would be great. Thank You.