Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Dont overwrite equal drafts #6212

Merged
merged 11 commits into from
Nov 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
immediately set timestamp
  • Loading branch information
Septias committed Nov 16, 2024
commit e670a328619cc4255119887db23f29198c053bd5
19 changes: 8 additions & 11 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,14 +927,15 @@ impl ChatId {
.transaction(|transaction| {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for transaction anymore.

let affected_rows = transaction.execute(
"UPDATE msgs
SET type=?1,txt=?2,txt_normalized=?3,param=?4,mime_in_reply_to=?5
WHERE id=?
AND (type <> ?1
OR txt <> ?2
OR txt_normalized <> ?3
OR param <> ?4
OR mime_in_reply_to <> ?5);",
SET timestamp=?1,type=?2,txt=?3,txt_normalized=?4,param=?5,mime_in_reply_to=?6
WHERE id=?7
AND (type <> ?2
OR txt <> ?3
OR txt_normalized <> ?4
OR param <> ?5
OR mime_in_reply_to <> ?6);",
(
time(),
msg.viewtype,
&msg.text,
message::normalize_text(&msg.text),
Expand All @@ -944,10 +945,6 @@ impl ChatId {
),
)?;
if affected_rows > 0 {
transaction.execute(
"UPDATE msgs SET timestamp=? WHERE id=?;",
(time(), msg.id),
)?;
Ok(true)
} else {
Ok(false)
Expand Down
Loading