mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix not updating/deleting the right label in the highlight
This commit is contained in:
parent
264ebef46e
commit
e0437008d7
1 changed files with 26 additions and 14 deletions
|
|
@ -106,18 +106,19 @@ export const deleteLabel = async (
|
|||
index: INDEX_ALIAS,
|
||||
body: {
|
||||
script: {
|
||||
source: `if (ctx._source.highlights != null && ctx._source.highlights[0].labels != null) {
|
||||
ctx._source.highlights[0].labels.removeIf(label -> label.name == params.label);
|
||||
ctx._source.updatedAt = params.updatedAt
|
||||
source: `if (ctx._source.highlights != null) {
|
||||
for (h in ctx._source.highlights) {
|
||||
if (h.labels != null) {
|
||||
h.labels.removeIf(l -> l.name == params.label)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ctx._source.labels != null) {
|
||||
ctx._source.labels.removeIf(label -> label.name == params.label);
|
||||
ctx._source.updatedAt = params.updatedAt
|
||||
}`,
|
||||
lang: 'painless',
|
||||
params: {
|
||||
label: label,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
},
|
||||
query: {
|
||||
|
|
@ -182,19 +183,30 @@ export const updateLabel = async (
|
|||
body: {
|
||||
script: {
|
||||
source: `if (ctx._source.labels != null) {
|
||||
ctx._source.labels.removeIf(l -> l.id == params.label.id);
|
||||
ctx._source.labels.add(params.label);
|
||||
ctx._source.updatedAt = params.updatedAt
|
||||
for (l in ctx._source.labels) {
|
||||
if (l.id == params.label.id) {
|
||||
l.name = params.label.name;
|
||||
l.color = params.label.color;
|
||||
l.description = params.description;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ctx._source.highlights != null && ctx._source.highlights[0].labels != null) {
|
||||
ctx._source.highlights[0].labels.removeIf(l -> l.id == params.label.id);
|
||||
ctx._source.highlights[0].labels.add(params.label);
|
||||
ctx._source.updatedAt = params.updatedAt
|
||||
if (ctx._source.highlights != null) {
|
||||
for (h in ctx._source.highlights) {
|
||||
if (h.labels != null) {
|
||||
for (l in h.labels) {
|
||||
if (l.id == params.label.id) {
|
||||
l.name = params.label.name;
|
||||
l.color = params.label.color;
|
||||
l.description = params.description;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
lang: 'painless',
|
||||
params: {
|
||||
label: label,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
},
|
||||
query: {
|
||||
|
|
@ -260,7 +272,7 @@ export const setLabelsForHighlight = async (
|
|||
index: INDEX_ALIAS,
|
||||
body: {
|
||||
script: {
|
||||
source: `ctx._source.highlights.stream().filter(h -> params.highlightId.equals(h.id)).findAny().orElse(null).labels = params.labels;
|
||||
source: `ctx._source.highlights.find(h -> params.highlightId == h.id).labels = params.labels;
|
||||
ctx._source.updatedAt = params.updatedAt`,
|
||||
lang: 'painless',
|
||||
params: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue