Merge pull request #1104 from omnivore-app/fix/update-label-script-exception

Fix getting script_exception when updating labels in highlights by checking null before updating
This commit is contained in:
Hongbo Wu 2022-08-19 15:35:55 +08:00 committed by GitHub
commit 31382a8b8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -186,7 +186,7 @@ export const updateLabel = async (
ctx._source.labels.add(params.label);
ctx._source.updatedAt = params.updatedAt
}
if (ctx._source.highlights != null) {
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