Skip to content

Commit

Permalink
Create group id based on the name
Browse files Browse the repository at this point in the history
This is to avoid creating duplicate groups based on the same name
  • Loading branch information
msasikanth committed Jul 30, 2024
1 parent 00a7eea commit ec4d38e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import app.cash.sqldelight.coroutines.asFlow
import app.cash.sqldelight.coroutines.mapToList
import app.cash.sqldelight.coroutines.mapToOne
import app.cash.sqldelight.paging3.QueryPagingSource
import com.benasher44.uuid.uuid4
import dev.sasikanth.rss.reader.core.model.local.Feed
import dev.sasikanth.rss.reader.core.model.local.FeedGroup
import dev.sasikanth.rss.reader.core.model.local.Post
Expand Down Expand Up @@ -524,7 +523,7 @@ class RssRepository(

suspend fun createGroup(name: String): String {
return withContext(ioDispatcher) {
val id = uuid4().toString()
val id = nameBasedUuidOf(name).toString()
feedGroupQueries.createGroup(
id = id,
name = name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SELECT
FROM feedGroup;

createGroup:
INSERT INTO feedGroup(id, name, feedIds, createdAt, updatedAt)
INSERT OR IGNORE INTO feedGroup(id, name, feedIds, createdAt, updatedAt)
VALUES (:id, :name, :feedIds, :createdAt, :updatedAt);

updateGroupName:
Expand Down

0 comments on commit ec4d38e

Please sign in to comment.