Skip to content

Commit

Permalink
Fix p2p swaps in threads which weren't being marked as updated (#5235)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Jan 23, 2024
1 parent cd11e1e commit 94a3849
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Fixed

- Fix p2p swaps in threads which weren't being marked as updated ([#5235](https://github.com/open-chat-labs/open-chat/pull/5235))

## [[2.0.1015](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1015-community)] - 2024-01-19

### Added
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/group/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Fixed

- Fix p2p swaps in threads which weren't being marked as updated ([#5235](https://github.com/open-chat-labs/open-chat/pull/5235))

## [[2.0.1016](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1016-group)] - 2024-01-19

### Added
Expand Down
18 changes: 12 additions & 6 deletions backend/libraries/chat_events/src/chat_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ impl ChatEvents {
{
if let MessageContentInternal::P2PSwap(content) = &mut message.content {
return if content.accept(user_id, token1_txn_in) {
self.last_updated_timestamps.mark_updated(None, event_index, now);
self.last_updated_timestamps
.mark_updated(thread_root_message_index, event_index, now);
AcceptP2PSwapResult::Success(P2PSwapAccepted {
accepted_by: user_id,
token1_txn_in,
Expand All @@ -778,7 +779,8 @@ impl ChatEvents {
{
if let MessageContentInternal::P2PSwap(content) = &mut message.content {
return if let Some(status) = content.complete(user_id, token0_txn_out, token1_txn_out) {
self.last_updated_timestamps.mark_updated(None, event_index, now);
self.last_updated_timestamps
.mark_updated(thread_root_message_index, event_index, now);
CompleteP2PSwapResult::Success(status)
} else {
CompleteP2PSwapResult::Failure(content.status.clone())
Expand All @@ -800,7 +802,8 @@ impl ChatEvents {
{
if let MessageContentInternal::P2PSwap(content) = &mut message.content {
if content.unreserve(user_id) {
self.last_updated_timestamps.mark_updated(None, event_index, now);
self.last_updated_timestamps
.mark_updated(thread_root_message_index, event_index, now);
};
}
}
Expand All @@ -820,7 +823,8 @@ impl ChatEvents {
if let MessageContentInternal::P2PSwap(content) = &mut message.content {
return if content.cancel() {
let swap_id = content.swap_id;
self.last_updated_timestamps.mark_updated(None, event_index, now);
self.last_updated_timestamps
.mark_updated(thread_root_message_index, event_index, now);
CancelP2PSwapResult::Success(swap_id)
} else {
CancelP2PSwapResult::Failure(content.status.clone())
Expand All @@ -842,7 +846,8 @@ impl ChatEvents {
{
if let MessageContentInternal::P2PSwap(content) = &mut message.content {
if content.mark_expired() {
self.last_updated_timestamps.mark_updated(None, event_index, now);
self.last_updated_timestamps
.mark_updated(thread_root_message_index, event_index, now);
};
}
}
Expand All @@ -860,7 +865,8 @@ impl ChatEvents {
{
if let MessageContentInternal::P2PSwap(content) = &mut message.content {
content.status = status;
self.last_updated_timestamps.mark_updated(None, event_index, now);
self.last_updated_timestamps
.mark_updated(thread_root_message_index, event_index, now);
}
}
}
Expand Down

0 comments on commit 94a3849

Please sign in to comment.