Skip to content

Commit

Permalink
Kim.update() API keeps "flag"/"pick" tag consistent with rating tag. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanOltmann authored May 10, 2024
1 parent 3733738 commit 3af7a13
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ of Ashampoo Photo Organizer, which, in turn, is driven by user community feedbac
## Installation

```
implementation("com.ashampoo:kim:0.18.1")
implementation("com.ashampoo:kim:0.18.2")
```

For the targets `wasmJs` & `js` you also need to specify this:
Expand Down
23 changes: 21 additions & 2 deletions src/commonMain/kotlin/com/ashampoo/kim/format/xmp/XmpWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.ashampoo.kim.format.xmp
import com.ashampoo.kim.Kim.underUnitTesting
import com.ashampoo.kim.common.GpsUtil
import com.ashampoo.kim.model.MetadataUpdate
import com.ashampoo.kim.model.PhotoRating
import com.ashampoo.xmp.XMPException
import com.ashampoo.xmp.XMPMeta
import com.ashampoo.xmp.XMPMetaFactory
Expand Down Expand Up @@ -77,12 +78,30 @@ public object XmpWriter {
deleteGpsCoordinates()
}

is MetadataUpdate.Flagged ->
is MetadataUpdate.Flagged -> {

setFlagged(update.flagged)

is MetadataUpdate.Rating ->
/*
* In the case of flagging/picking a photo a rejected
* rating will be reset to UNRATED for logical consistency.
*/
if (update.flagged && getRating() == PhotoRating.REJECTED.value)
setRating(PhotoRating.UNRATED.value)
}

is MetadataUpdate.Rating -> {

setRating(update.photoRating.value)

/*
* In the case of rejecting a photo a flag/pick marker
* will be removed for logical consistency.
*/
if (update.photoRating == PhotoRating.REJECTED && isFlagged())
setFlagged(false)
}

is MetadataUpdate.Keywords ->
setKeywords(update.keywords)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public sealed interface MetadataUpdate {

/**
* Set a photo as flagged/tagged/picked.
*
* In the case of flagging/picking a photo a rejected
* rating will be reset to UNRATED for logical consistency.
*/
public data class Flagged(
val flagged: Boolean
Expand All @@ -53,6 +56,9 @@ public sealed interface MetadataUpdate {
/**
* Set a new Rating.
* Can't be NULL and should be UNRATED instead.
*
* In the case of rejecting a photo a flag/pick marker
* will be removed for logical consistency.
*/
public data class Rating(
val photoRating: PhotoRating
Expand Down

0 comments on commit 3af7a13

Please sign in to comment.