Add in mark as reaad button to list view, use ajax to preform the action without page refresh.
This commit is contained in:
@@ -277,3 +277,25 @@ func (s *Service) Unarchive(userID, id int64) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) MarkRead(userID, id int64) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), s.Timeout)
|
||||
defer cancel()
|
||||
|
||||
q := `
|
||||
UPDATE user_messages
|
||||
SET is_read = 1
|
||||
WHERE id = ? AND recipientId = ?
|
||||
`
|
||||
q = s.bind(q)
|
||||
|
||||
res, err := s.DB.ExecContext(ctx, q, id, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n, _ := res.RowsAffected()
|
||||
if n == 0 {
|
||||
return sql.ErrNoRows
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user