status-go/protocol/persistence_collapsed_community_categories.go
frank b6d4e75cf1
Feat/sync activity center notification (#3535)
fix flaky test: TestRetrieveBlockedContact

resolve conflict when rebase origin/develop

Feat/sync activity center notification (#3581)

* feat: sync activity center notification

* add test

* fix lint issue

* fix failed test

* addressed feedback from sale

* fix failed test

* addressed feedback from ilmotta

go generate ./protocol/migrations/sqlite/...

feat: add updated_at for syncing activity center notification
2023-06-10 10:00:17 +08:00

41 lines
1 KiB
Go

package protocol
func (db *sqlitePersistence) UpsertCollapsedCommunityCategory(category CollapsedCommunityCategory) error {
var err error
if category.Collapsed {
_, err = db.db.Exec("INSERT INTO collapsed_community_categories(community_id, category_id) VALUES(?,?)", category.CommunityID, category.CategoryID)
} else {
_, err = db.db.Exec("DELETE FROM collapsed_community_categories WHERE community_id = ? AND category_id = ?", category.CommunityID, category.CategoryID)
}
return err
}
func (db *sqlitePersistence) CollapsedCommunityCategories() ([]CollapsedCommunityCategory, error) {
var categories []CollapsedCommunityCategory
rows, err := db.db.Query(`
SELECT
community_id,
category_id
FROM
collapsed_community_categories
`)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
var c CollapsedCommunityCategory
err = rows.Scan(
&c.CommunityID,
&c.CategoryID,
)
if err != nil {
return nil, err
}
categories = append(categories, c)
}
return categories, nil
}