diff --git a/pkg/hicli/database/room.go b/pkg/hicli/database/room.go index 31eeb5f..8c000c8 100644 --- a/pkg/hicli/database/room.go +++ b/pkg/hicli/database/room.go @@ -132,6 +132,9 @@ func (rq *RoomQuery) UpdatePreviewIfLaterOnTimeline(ctx context.Context, roomID func (rq *RoomQuery) RecalculatePreview(ctx context.Context, roomID id.RoomID) (rowID EventRowID, err error) { err = rq.GetDB().QueryRow(ctx, recalculateRoomPreviewEventQuery, roomID).Scan(&rowID) + if errors.Is(err, sql.ErrNoRows) { + err = nil + } return } diff --git a/pkg/hicli/sync.go b/pkg/hicli/sync.go index 2acf12d..0d8e86c 100644 --- a/pkg/hicli/sync.go +++ b/pkg/hicli/sync.go @@ -969,10 +969,11 @@ func (h *HiClient) processStateAndTimeline( updatedRoom.PreviewEventRowID, err = h.DB.Room.RecalculatePreview(ctx, room.ID) if err != nil { return fmt.Errorf("failed to recalculate preview event: %w", err) - } - _, err = addOldEvent(updatedRoom.PreviewEventRowID, "") - if err != nil { - return fmt.Errorf("failed to get preview event: %w", err) + } else if updatedRoom.PreviewEventRowID != 0 { + _, err = addOldEvent(updatedRoom.PreviewEventRowID, "") + if err != nil { + return fmt.Errorf("failed to get preview event: %w", err) + } } } // Calculate name from participants if participants changed and current name was generated from participants, or if the room name was unset