feat: Synchronize shaarli-pin tag with isPinned status in FeedViewModel and PinnedViewModel
- Add automatic shaarli-pin tag management when toggling pin status - Add shaarli-pin tag when pinning a link (if not already present) - Remove shaarli-pin tag when unpinning a link - Update both pin status and tags atomically in togglePin() methods - Bump version to 2.1.7 (VERSION_CODE 22)
This commit is contained in:
parent
bb6c54e7e5
commit
2358ed68b2
@ -194,7 +194,14 @@ class FeedViewModel @Inject constructor(
|
|||||||
fun togglePin(id: Int) {
|
fun togglePin(id: Int) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
linkDao.getLinkById(id)?.let { link ->
|
linkDao.getLinkById(id)?.let { link ->
|
||||||
linkDao.updatePinStatus(id, !link.isPinned)
|
val newPinned = !link.isPinned
|
||||||
|
val newTags = if (newPinned) {
|
||||||
|
if ("shaarli-pin" !in link.tags) link.tags + "shaarli-pin" else link.tags
|
||||||
|
} else {
|
||||||
|
link.tags - "shaarli-pin"
|
||||||
|
}
|
||||||
|
linkDao.updatePinStatus(id, newPinned)
|
||||||
|
linkDao.updateLinkTags(id, newTags)
|
||||||
_refreshTrigger.value++
|
_refreshTrigger.value++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,14 @@ class PinnedViewModel @Inject constructor(
|
|||||||
fun togglePin(id: Int) {
|
fun togglePin(id: Int) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
linkDao.getLinkById(id)?.let { link ->
|
linkDao.getLinkById(id)?.let { link ->
|
||||||
linkDao.updatePinStatus(id, !link.isPinned)
|
val newPinned = !link.isPinned
|
||||||
|
val newTags = if (newPinned) {
|
||||||
|
if ("shaarli-pin" !in link.tags) link.tags + "shaarli-pin" else link.tags
|
||||||
|
} else {
|
||||||
|
link.tags - "shaarli-pin"
|
||||||
|
}
|
||||||
|
linkDao.updatePinStatus(id, newPinned)
|
||||||
|
linkDao.updateLinkTags(id, newTags)
|
||||||
_refreshTrigger.value++
|
_refreshTrigger.value++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
#Fri Feb 13 22:32:44 2026
|
#Sat Feb 14 15:58:10 2026
|
||||||
VERSION_NAME=2.1.6
|
VERSION_NAME=2.1.7
|
||||||
VERSION_CODE=21
|
VERSION_CODE=22
|
||||||
Loading…
x
Reference in New Issue
Block a user