Simplify status updating code, start to add edit labels

This commit is contained in:
Jackson Harper
2023-03-20 13:36:11 +08:00
parent 74c2969b03
commit 93c19ecdea
6 changed files with 287 additions and 96 deletions

View File

@ -118,6 +118,7 @@ function savePdfFile(tab, url, contentType, contentObjUrl) {
action: ACTIONS.UpdateStatus,
payload: {
status: 'success',
target: 'page',
requestId: createdPageId,
},
})
@ -212,6 +213,7 @@ function handleSaveResponse(tab, field, xhr) {
action: ACTIONS.UpdateStatus,
payload: {
status: 'success',
target: 'page',
link: url ?? omnivoreURL + '/home',
},
})
@ -770,12 +772,35 @@ function init() {
}
if (request.action === ACTIONS.EditTitle) {
console.log('EDITING TITLE REQUEST: ')
updatePageTitle(
omnivoreGraphqlURL + 'graphql',
request.payload.pageId,
request.payload.title
)
).then(() => {
browserApi.tabs.sendMessage(sender.tab.id, {
action: ACTIONS.UpdateStatus,
payload: {
target: 'title',
status: 'success',
},
})
})
}
if (request.action === ACTIONS.SetLabels) {
setLabels(
omnivoreGraphqlURL + 'graphql',
request.payload.pageId,
request.payload.labelIds
).then(() => {
browserApi.tabs.sendMessage(sender.tab.id, {
action: ACTIONS.UpdateStatus,
payload: {
target: 'labels',
status: 'success',
},
})
})
}
})