fix recent notes (db & sync version increase)

This commit is contained in:
zadam 2019-05-21 21:47:28 +02:00
parent ced02b42b5
commit 29828f8e8f
16 changed files with 196 additions and 176 deletions

View File

@ -0,0 +1,12 @@
drop table recent_notes;
create table recent_notes
(
noteId TEXT not null primary key,
notePath TEXT not null,
hash TEXT default "" not null,
utcDateCreated TEXT not null,
isDeleted INT
);
delete from sync where entityName = 'recent_notes';

View File

@ -28,7 +28,7 @@
<header> <header>
<h2><span class="attribs"><span class="type-signature"></span></span>RecentNote<span class="signature">(branchId, notePath, isDeleted, utcDateModified)</span><span class="type-signature"></span></h2> <h2><span class="attribs"><span class="type-signature"></span></span>RecentNote<span class="signature">(noteId, notePath, isDeleted, utcDateModified)</span><span class="type-signature"></span></h2>
<div class="class-description">RecentNote represents recently visited note.</div> <div class="class-description">RecentNote represents recently visited note.</div>
@ -45,7 +45,7 @@
<h4 class="name" id="RecentNote"><span class="type-signature"></span>new RecentNote<span class="signature">(branchId, notePath, isDeleted, utcDateModified)</span><span class="type-signature"></span></h4> <h4 class="name" id="RecentNote"><span class="type-signature"></span>new RecentNote<span class="signature">(noteId, notePath, isDeleted, utcDateModified)</span><span class="type-signature"></span></h4>
@ -85,7 +85,7 @@
<tr> <tr>
<td class="name"><code>branchId</code></td> <td class="name"><code>noteId</code></td>
<td class="type"> <td class="type">

View File

@ -34,7 +34,7 @@ const dateUtils = require('../services/date_utils');
/** /**
* RecentNote represents recently visited note. * RecentNote represents recently visited note.
* *
* @param {string} branchId * @param {string} noteId
* @param {string} notePath * @param {string} notePath
* @param {boolean} isDeleted * @param {boolean} isDeleted
* @param {string} utcDateModified * @param {string} utcDateModified
@ -43,8 +43,8 @@ const dateUtils = require('../services/date_utils');
*/ */
class RecentNote extends Entity { class RecentNote extends Entity {
static get entityName() { return "recent_notes"; } static get entityName() { return "recent_notes"; }
static get primaryKeyName() { return "branchId"; } static get primaryKeyName() { return "noteId"; }
static get hashedProperties() { return ["branchId", "notePath", "utcDateCreated", "isDeleted"]; } static get hashedProperties() { return ["noteId", "notePath", "utcDateCreated", "isDeleted"]; }
beforeSaving() { beforeSaving() {
if (!this.isDeleted) { if (!this.isDeleted) {

View File

@ -461,6 +461,115 @@
<h4 class="name" id="tabContext"><span class="type-signature"></span>tabContext<span class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="type">
<span class="param-type">TabContext</span>
|
<span class="param-type">null</span>
</td>
<td class="description last">experimental!</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line33">line 33</a>
</li></ul></dd>
</dl>
@ -573,7 +682,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line47">line 47</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line50">line 50</a>
</li></ul></dd> </li></ul></dd>
@ -726,7 +835,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line39">line 39</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line42">line 42</a>
</li></ul></dd> </li></ul></dd>
@ -879,7 +988,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line66">line 66</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line69">line 69</a>
</li></ul></dd> </li></ul></dd>
@ -1057,7 +1166,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line255">line 255</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line258">line 258</a>
</li></ul></dd> </li></ul></dd>
@ -1188,7 +1297,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line215">line 215</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line218">line 218</a>
</li></ul></dd> </li></ul></dd>
@ -1292,7 +1401,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line267">line 267</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line264">line 264</a>
</li></ul></dd> </li></ul></dd>
@ -1348,7 +1457,7 @@
<h4 class="name" id="getActiveNoteContent"><span class="type-signature"></span>getActiveNoteContent<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4> <h4 class="name" id="getActiveNotePath"><span class="type-signature"></span>getActiveNotePath<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;(string|null)>}</span></h4>
@ -1396,7 +1505,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line261">line 261</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line270">line 270</a>
</li></ul></dd> </li></ul></dd>
@ -1423,7 +1532,7 @@
<div class="param-desc"> <div class="param-desc">
content of active note (loaded into right pane) returns note path of active note or null if there isn't active note
</div> </div>
@ -1434,111 +1543,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">string</span> <span class="param-type">Promise.&lt;(string|null)></span>
</dd>
</dl>
<h4 class="name" id="getActiveNotePath"><span class="type-signature"></span>getActiveNotePath<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;string>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line273">line 273</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
returns note path of active note
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;string></span>
</dd> </dd>
@ -1604,7 +1609,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line304">line 304</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line305">line 305</a>
</li></ul></dd> </li></ul></dd>
@ -1761,7 +1766,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line338">line 338</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line339">line 339</a>
</li></ul></dd> </li></ul></dd>
@ -1861,7 +1866,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line298">line 298</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line299">line 299</a>
</li></ul></dd> </li></ul></dd>
@ -1970,7 +1975,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line208">line 208</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line211">line 211</a>
</li></ul></dd> </li></ul></dd>
@ -2123,7 +2128,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line347">line 347</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line348">line 348</a>
</li></ul></dd> </li></ul></dd>
@ -2277,7 +2282,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line176">line 176</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line179">line 179</a>
</li></ul></dd> </li></ul></dd>
@ -2476,7 +2481,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line188">line 188</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line191">line 191</a>
</li></ul></dd> </li></ul></dd>
@ -2580,7 +2585,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line329">line 329</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line330">line 330</a>
</li></ul></dd> </li></ul></dd>
@ -2733,7 +2738,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line356">line 356</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line357">line 357</a>
</li></ul></dd> </li></ul></dd>
@ -2840,7 +2845,7 @@ note.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line284">line 284</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line285">line 285</a>
</li></ul></dd> </li></ul></dd>
@ -2993,7 +2998,7 @@ note.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line292">line 292</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line293">line 293</a>
</li></ul></dd> </li></ul></dd>
@ -3124,7 +3129,7 @@ note.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line222">line 222</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line225">line 225</a>
</li></ul></dd> </li></ul></dd>
@ -3228,7 +3233,7 @@ note.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line321">line 321</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line322">line 322</a>
</li></ul></dd> </li></ul></dd>
@ -3314,7 +3319,7 @@ note.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line246">line 246</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line249">line 249</a>
</li></ul></dd> </li></ul></dd>
@ -3463,7 +3468,7 @@ note.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line194">line 194</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line197">line 197</a>
</li></ul></dd> </li></ul></dd>
@ -3594,7 +3599,7 @@ note.
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line200">line 200</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line203">line 203</a>
</li></ul></dd> </li></ul></dd>
@ -3753,7 +3758,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line116">line 116</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line119">line 119</a>
</li></ul></dd> </li></ul></dd>
@ -3911,7 +3916,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line164">line 164</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line167">line 167</a>
</li></ul></dd> </li></ul></dd>
@ -4065,7 +4070,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line146">line 146</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line149">line 149</a>
</li></ul></dd> </li></ul></dd>
@ -4214,7 +4219,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line310">line 310</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line311">line 311</a>
</li></ul></dd> </li></ul></dd>
@ -4345,7 +4350,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line316">line 316</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line317">line 317</a>
</li></ul></dd> </li></ul></dd>
@ -4480,7 +4485,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line238">line 238</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line241">line 241</a>
</li></ul></dd> </li></ul></dd>
@ -4615,7 +4620,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line230">line 230</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line233">line 233</a>
</li></ul></dd> </li></ul></dd>

View File

@ -303,7 +303,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line53">line 53</a> <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line56">line 56</a>
</li></ul></dd> </li></ul></dd>

View File

@ -44,7 +44,7 @@ import dateNotesService from'./date_notes.js';
* @constructor * @constructor
* @hideconstructor * @hideconstructor
*/ */
function FrontendScriptApi(startNote, currentNote, originEntity = null) { function FrontendScriptApi(startNote, currentNote, originEntity = null, tabContext = null) {
const $pluginButtons = $("#plugin-buttons"); const $pluginButtons = $("#plugin-buttons");
/** @property {object} note where script started executing */ /** @property {object} note where script started executing */
@ -57,6 +57,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
// to keep consistency with backend API // to keep consistency with backend API
this.dayjs = dayjs; this.dayjs = dayjs;
/** @property {TabContext|null} - experimental! */
this.tabContext = tabContext;
/** /**
* Activates note in the tree and in the note detail. * Activates note in the tree and in the note detail.
* *
@ -282,12 +285,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
*/ */
this.createNoteLink = linkService.createNoteLink; this.createNoteLink = linkService.createNoteLink;
/**
* @method
* @returns {string} content of active note (loaded into right pane)
*/
this.getActiveNoteContent = noteDetailService.getActiveNoteContent;
/** /**
* @method * @method
* @returns {NoteFull} active note (loaded into right pane) * @returns {NoteFull} active note (loaded into right pane)
@ -296,9 +293,13 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
/** /**
* @method * @method
* @returns {Promise&lt;string>} returns note path of active note * @returns {Promise&lt;string|null>} returns note path of active note or null if there isn't active note
*/ */
this.getActiveNotePath = treeService.getActiveNotePath; this.getActiveNotePath = () => {
const activeTabContext = noteDetailService.getActiveTabContext();
return activeTabContext ? activeTabContext.notePath : null;
};
/** /**
* This method checks whether user navigated away from the note from which the scripts has been started. * This method checks whether user navigated away from the note from which the scripts has been started.

View File

@ -6,7 +6,7 @@ const dateUtils = require('../services/date_utils');
/** /**
* RecentNote represents recently visited note. * RecentNote represents recently visited note.
* *
* @param {string} branchId * @param {string} noteId
* @param {string} notePath * @param {string} notePath
* @param {boolean} isDeleted * @param {boolean} isDeleted
* @param {string} utcDateModified * @param {string} utcDateModified
@ -15,8 +15,8 @@ const dateUtils = require('../services/date_utils');
*/ */
class RecentNote extends Entity { class RecentNote extends Entity {
static get entityName() { return "recent_notes"; } static get entityName() { return "recent_notes"; }
static get primaryKeyName() { return "branchId"; } static get primaryKeyName() { return "noteId"; }
static get hashedProperties() { return ["branchId", "notePath", "utcDateCreated", "isDeleted"]; } static get hashedProperties() { return ["noteId", "notePath", "utcDateCreated", "isDeleted"]; }
beforeSaving() { beforeSaving() {
if (!this.isDeleted) { if (!this.isDeleted) {

View File

@ -94,6 +94,7 @@ class TabContext {
this.attributes.invalidateAttributes(); this.attributes.invalidateAttributes();
this.$noteTitleRow.show(); // might be hidden from empty detail
this.$tabContent.toggleClass("protected", this.note.isProtected); this.$tabContent.toggleClass("protected", this.note.isProtected);
this.$protectButton.toggleClass("active", this.note.isProtected); this.$protectButton.toggleClass("active", this.note.isProtected);
this.$protectButton.prop("disabled", this.note.isProtected); this.$protectButton.prop("disabled", this.note.isProtected);
@ -106,8 +107,11 @@ class TabContext {
setTimeout(async () => { setTimeout(async () => {
// we include the note into recent list only if the user stayed on the note at least 5 seconds // we include the note into recent list only if the user stayed on the note at least 5 seconds
if (notePath && notePath === await this.notePath) { if (notePath && notePath === this.notePath) {
await server.post('recent-notes', { notePath }); await server.post('recent-notes', {
noteId: this.noteId,
notePath: this.notePath
});
} }
}, 5000); }, 5000);

View File

@ -43,11 +43,11 @@ async function getRecentNotes(activeNoteId) {
recent_notes.* recent_notes.*
FROM FROM
recent_notes recent_notes
JOIN branches USING(branchId) JOIN notes USING(noteId)
WHERE WHERE
recent_notes.isDeleted = 0 recent_notes.isDeleted = 0
AND branches.isDeleted = 0 AND notes.isDeleted = 0
AND branches.noteId != ? AND notes.noteId != ?
${extraCondition} ${extraCondition}
ORDER BY ORDER BY
utcDateCreated DESC utcDateCreated DESC

View File

@ -3,12 +3,9 @@
const RecentNote = require('../../entities/recent_note'); const RecentNote = require('../../entities/recent_note');
async function addRecentNote(req) { async function addRecentNote(req) {
const branchId = req.body.branchId;
const notePath = req.body.notePath;
await new RecentNote({ await new RecentNote({
branchId: branchId, noteId: req.body.noteId,
notePath: notePath notePath: req.body.notePath
}).save(); }).save();
} }

View File

@ -78,13 +78,14 @@ async function forceNoteSync(req) {
for (const branchId of await sql.getColumn("SELECT branchId FROM branches WHERE isDeleted = 0 AND noteId = ?", [noteId])) { for (const branchId of await sql.getColumn("SELECT branchId FROM branches WHERE isDeleted = 0 AND noteId = ?", [noteId])) {
await syncTableService.addBranchSync(branchId); await syncTableService.addBranchSync(branchId);
await syncTableService.addRecentNoteSync(branchId);
} }
for (const noteRevisionId of await sql.getColumn("SELECT noteRevisionId FROM note_revisions WHERE noteId = ?", [noteId])) { for (const noteRevisionId of await sql.getColumn("SELECT noteRevisionId FROM note_revisions WHERE noteId = ?", [noteId])) {
await syncTableService.addNoteRevisionSync(noteRevisionId); await syncTableService.addNoteRevisionSync(noteRevisionId);
} }
await syncTableService.addRecentNoteSync(noteId);
log.info("Forcing note sync for " + noteId); log.info("Forcing note sync for " + noteId);
// not awaiting for the job to finish (will probably take a long time) // not awaiting for the job to finish (will probably take a long time)

View File

@ -4,8 +4,8 @@ const build = require('./build');
const packageJson = require('../../package'); const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir'); const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 135; const APP_DB_VERSION = 136;
const SYNC_VERSION = 8; const SYNC_VERSION = 9;
module.exports = { module.exports = {
appVersion: packageJson.version, appVersion: packageJson.version,

View File

@ -396,7 +396,7 @@ async function findSyncRowsIssues() {
await runSyncRowChecks("note_contents", "noteId"); await runSyncRowChecks("note_contents", "noteId");
await runSyncRowChecks("note_revisions", "noteRevisionId"); await runSyncRowChecks("note_revisions", "noteRevisionId");
await runSyncRowChecks("branches", "branchId"); await runSyncRowChecks("branches", "branchId");
await runSyncRowChecks("recent_notes", "branchId"); await runSyncRowChecks("recent_notes", "noteId");
await runSyncRowChecks("attributes", "attributeId"); await runSyncRowChecks("attributes", "attributeId");
await runSyncRowChecks("api_tokens", "apiTokenId"); await runSyncRowChecks("api_tokens", "apiTokenId");
await runSyncRowChecks("options", "name"); await runSyncRowChecks("options", "name");

View File

@ -246,7 +246,7 @@ const primaryKeys = {
"note_contents": "noteId", "note_contents": "noteId",
"branches": "branchId", "branches": "branchId",
"note_revisions": "noteRevisionId", "note_revisions": "noteRevisionId",
"recent_notes": "branchId", "recent_notes": "noteId",
"api_tokens": "apiTokenId", "api_tokens": "apiTokenId",
"options": "name", "options": "name",
"attributes": "attributeId", "attributes": "attributeId",

View File

@ -28,8 +28,8 @@ async function addOptionsSync(name, sourceId) {
await addEntitySync("options", name, sourceId); await addEntitySync("options", name, sourceId);
} }
async function addRecentNoteSync(branchId, sourceId) { async function addRecentNoteSync(noteId, sourceId) {
await addEntitySync("recent_notes", branchId, sourceId); await addEntitySync("recent_notes", noteId, sourceId);
} }
async function addLinkSync(linkId, sourceId) { async function addLinkSync(linkId, sourceId) {
@ -91,7 +91,7 @@ async function fillAllSyncRows() {
await fillSyncRows("note_contents", "noteId"); await fillSyncRows("note_contents", "noteId");
await fillSyncRows("branches", "branchId"); await fillSyncRows("branches", "branchId");
await fillSyncRows("note_revisions", "noteRevisionId"); await fillSyncRows("note_revisions", "noteRevisionId");
await fillSyncRows("recent_notes", "branchId"); await fillSyncRows("recent_notes", "noteId");
await fillSyncRows("attributes", "attributeId"); await fillSyncRows("attributes", "attributeId");
await fillSyncRows("api_tokens", "apiTokenId"); await fillSyncRows("api_tokens", "apiTokenId");
await fillSyncRows("links", "linkId"); await fillSyncRows("links", "linkId");

View File

@ -148,13 +148,13 @@ async function updateOptions(entity, sourceId) {
} }
async function updateRecentNotes(entity, sourceId) { async function updateRecentNotes(entity, sourceId) {
const orig = await sql.getRowOrNull("SELECT * FROM recent_notes WHERE branchId = ?", [entity.branchId]); const orig = await sql.getRowOrNull("SELECT * FROM recent_notes WHERE noteId = ?", [entity.noteId]);
if (orig === null || orig.utcDateCreated < entity.utcDateCreated) { if (orig === null || orig.utcDateCreated < entity.utcDateCreated) {
await sql.transactional(async () => { await sql.transactional(async () => {
await sql.replace('recent_notes', entity); await sql.replace('recent_notes', entity);
await syncTableService.addRecentNoteSync(entity.branchId, sourceId); await syncTableService.addRecentNoteSync(entity.noteId, sourceId);
}); });
} }
} }