2019-03-18 22:33:19 +01:00
|
|
|
import treeCache from './tree_cache.js';
|
2018-03-30 13:20:36 -04:00
|
|
|
import server from './server.js';
|
2020-01-24 15:44:24 +01:00
|
|
|
import appContext from "./app_context.js";
|
2018-03-25 11:09:17 -04:00
|
|
|
|
|
|
|
async function cloneNoteTo(childNoteId, parentNoteId, prefix) {
|
|
|
|
const resp = await server.put('notes/' + childNoteId + '/clone-to/' + parentNoteId, {
|
|
|
|
prefix: prefix
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!resp.success) {
|
|
|
|
alert(resp.message);
|
2018-01-13 18:02:41 -05:00
|
|
|
}
|
2018-03-25 11:09:17 -04:00
|
|
|
}
|
2018-01-13 18:02:41 -05:00
|
|
|
|
2018-03-25 11:09:17 -04:00
|
|
|
// beware that first arg is noteId and second is branchId!
|
|
|
|
async function cloneNoteAfter(noteId, afterBranchId) {
|
|
|
|
const resp = await server.put('notes/' + noteId + '/clone-after/' + afterBranchId);
|
2018-01-13 18:02:41 -05:00
|
|
|
|
2018-03-25 11:09:17 -04:00
|
|
|
if (!resp.success) {
|
|
|
|
alert(resp.message);
|
|
|
|
return;
|
2018-01-13 18:02:41 -05:00
|
|
|
}
|
|
|
|
|
2019-10-26 09:58:00 +02:00
|
|
|
const afterBranch = treeCache.getBranch(afterBranchId);
|
2018-03-25 11:09:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
cloneNoteAfter,
|
|
|
|
cloneNoteTo
|
|
|
|
};
|