fix attribute loading for mobile

This commit is contained in:
azivner 2018-12-24 23:08:43 +01:00
parent f8d32d64f5
commit 246dfbdcb4
2 changed files with 19 additions and 2 deletions

View file

@ -13,13 +13,25 @@ const $savedIndicator = $("#saved-indicator");
let attributePromise; let attributePromise;
async function refreshAttributes() { function invalidateAttributes() {
attributePromise = null;
}
function reloadAttributes() {
attributePromise = server.get('notes/' + noteDetailService.getCurrentNoteId() + '/attributes'); attributePromise = server.get('notes/' + noteDetailService.getCurrentNoteId() + '/attributes');
}
async function refreshAttributes() {
reloadAttributes();
await showAttributes(); await showAttributes();
} }
async function getAttributes() { async function getAttributes() {
if (!attributePromise) {
reloadAttributes();
}
return await attributePromise; return await attributePromise;
} }
@ -286,5 +298,6 @@ async function promotedAttributeChanged(event) {
export default { export default {
getAttributes, getAttributes,
showAttributes, showAttributes,
refreshAttributes refreshAttributes,
invalidateAttributes
} }

View file

@ -182,6 +182,10 @@ async function loadNoteDetail(noteId) {
// needs to happen after loading the note itself because it references current noteId // needs to happen after loading the note itself because it references current noteId
attributeService.refreshAttributes(); attributeService.refreshAttributes();
} }
else {
// mobile usually doesn't need attributes so we just invalidate
attributeService.invalidateAttributes();
}
if (isNewNoteCreated) { if (isNewNoteCreated) {
isNewNoteCreated = false; isNewNoteCreated = false;