chore_: Remove switcher cards (#6107)

This commit is contained in:
Parvesh Monu 2024-11-19 13:41:52 +05:30 committed by GitHub
parent f754315023
commit 17dbc37964
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 1 additions and 129 deletions

View File

@ -0,0 +1 @@
DROP TABLE switcher_cards;

View File

@ -1,26 +0,0 @@
package protocol
import "github.com/status-im/status-go/protocol/requests"
func (m *Messenger) UpsertSwitcherCard(request *requests.UpsertSwitcherCard) error {
if err := request.Validate(); err != nil {
return err
}
switcherCard := SwitcherCard{
CardID: request.CardID,
Type: request.Type,
Clock: request.Clock,
ScreenID: request.ScreenID,
}
return m.persistence.UpsertSwitcherCard(switcherCard)
}
func (m *Messenger) DeleteSwitcherCard(cardID string) error {
return m.persistence.DeleteSwitcherCard(cardID)
}
func (m *Messenger) SwitcherCards() ([]SwitcherCard, error) {
return m.persistence.SwitcherCards()
}

View File

@ -1189,58 +1189,6 @@ func (db sqlitePersistence) StatusUpdates() (statusUpdates []UserStatus, err err
return
}
func (db sqlitePersistence) DeleteSwitcherCard(cardID string) error {
_, err := db.db.Exec("DELETE from switcher_cards WHERE card_id = ?", cardID)
return err
}
func (db sqlitePersistence) UpsertSwitcherCard(switcherCard SwitcherCard) error {
_, err := db.db.Exec(`INSERT INTO switcher_cards(
card_id,
type,
clock,
screen_id)
VALUES (?, ?, ?, ?)`,
switcherCard.CardID,
switcherCard.Type,
switcherCard.Clock,
switcherCard.ScreenID,
)
return err
}
func (db sqlitePersistence) SwitcherCards() (switcherCards []SwitcherCard, err error) {
rows, err := db.db.Query(`
SELECT
card_id,
type,
clock,
screen_id
FROM switcher_cards
`)
if err != nil {
return
}
defer rows.Close()
for rows.Next() {
var switcherCard SwitcherCard
err = rows.Scan(
&switcherCard.CardID,
&switcherCard.Type,
&switcherCard.Clock,
&switcherCard.ScreenID,
)
if err != nil {
return
}
switcherCards = append(switcherCards, switcherCard)
}
return
}
func (db sqlitePersistence) NextHigherClockValueOfAutomaticStatusUpdates(clock uint64) (uint64, error) {
var nextClock uint64

View File

@ -1,20 +0,0 @@
package requests
import "errors"
var ErrUpsertSwitcherCardInvalidCardID = errors.New("upsert-switcher-card: invalid card id")
type UpsertSwitcherCard struct {
CardID string `json:"cardId,omitempty"`
Type int `json:"type"`
Clock uint64 `json:"clock"`
ScreenID string `json:"screenId"`
}
func (a *UpsertSwitcherCard) Validate() error {
if len(a.CardID) == 0 {
return ErrUpsertSwitcherCardInvalidCardID
}
return nil
}

View File

@ -1,8 +0,0 @@
package protocol
type SwitcherCard struct {
CardID string `json:"cardId,omitempty"`
Type int `json:"type"`
Clock uint64 `json:"clock"`
ScreenID string `json:"screenId"`
}

View File

@ -730,10 +730,6 @@ type ApplicationStatusUpdatesResponse struct {
StatusUpdates []protocol.UserStatus `json:"statusUpdates"`
}
type ApplicationSwitcherCardsResponse struct {
SwitcherCards []protocol.SwitcherCard `json:"switcherCards"`
}
func (api *PublicAPI) ChatMessages(chatID, cursor string, limit int) (*ApplicationMessagesResponse, error) {
messages, cursor, err := api.service.messenger.MessageByChatID(chatID, cursor, limit)
if err != nil {
@ -799,25 +795,6 @@ func (api *PublicAPI) StatusUpdates() (*ApplicationStatusUpdatesResponse, error)
}, nil
}
func (api *PublicAPI) UpsertSwitcherCard(request *requests.UpsertSwitcherCard) error {
return api.service.messenger.UpsertSwitcherCard(request)
}
func (api *PublicAPI) DeleteSwitcherCard(id string) error {
return api.service.messenger.DeleteSwitcherCard(id)
}
func (api *PublicAPI) SwitcherCards() (*ApplicationSwitcherCardsResponse, error) {
switcherCards, err := api.service.messenger.SwitcherCards()
if err != nil {
return nil, err
}
return &ApplicationSwitcherCardsResponse{
SwitcherCards: switcherCards,
}, nil
}
func (api *PublicAPI) StartMessenger() (*protocol.MessengerResponse, error) {
return api.service.StartMessenger()
}