-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the text is the same, but quote is different?
src/chat.rs
Outdated
let self_chat = alice.get_self_chat().await.id; | ||
self_chat.set_draft(&alice, Some(&mut msg)).await.unwrap(); | ||
let draft1 = self_chat.get_draft(&alice).await?.unwrap(); | ||
tokio::time::sleep(Duration::from_millis(800)).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use SystemTime::shift
?
Ah true, quote should probably also be checked. We definitely need to update but maybe we can just update the quote and don't touch timestamp. |
Co-authored-by: l <link2xt@testrun.org>
Co-authored-by: l <link2xt@testrun.org>
48cc5a3
to
9bcd84b
Compare
Why not change the timestamp if the quote is updated? Instead of all these checks that need to be synchronized, can |
Another option is to make it a transaction which first updates everything except the timestamp and if the number of changed rows != 0, updates the timestamp as well. |
src/chat.rs
Outdated
), | ||
)?; | ||
if affected_rows > 0 { | ||
transaction.execute("UPDATE msgs SET timestamp=? WHERE id=?;", (time(),msg.id))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could update the timestamp
in the same UPDATE
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but then we would anyways update the timestamp and hence move that chat to the top, exactly what we are trying to avoid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not if there is a WHERE
check.
src/chat.rs
Outdated
) | ||
.await?; | ||
return Ok(true); | ||
.transaction(|transaction| { |
There was a problem hiding this comment.
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.
msg.id, | ||
), | ||
).await?; | ||
if affected_rows > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Ok(affected_rows > 0)
This PR prevents overwriting drafts when the text and file are the same.
close #6211