Skip to content

Commit

Permalink
Clear the principal to userId map to ensure latest values are used (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Aug 2, 2024
1 parent 000176d commit a6a8c38
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions backend/canisters/online_users/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Added `c2c_remove_user` to be called by the UserIndex ([#6179](https://github.com/open-chat-labs/open-chat/pull/6179))

### Changed

- Clear the principal to userId map to ensure latest values are used ([#6184](https://github.com/open-chat-labs/open-chat/pull/6184))

## [[2.0.1149](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1149-online_users)] - 2024-04-23

### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::lifecycle::{init_env, init_state};
use crate::memory::get_upgrades_memory;
use crate::Data;
use crate::{mutate_state, Data};
use canister_logger::LogEntry;
use canister_tracing_macros::trace;
use ic_cdk::post_upgrade;
Expand All @@ -24,4 +24,7 @@ fn post_upgrade(args: Args) {
init_state(env, data, args.wasm_version);

info!(version = %args.wasm_version, "Post-upgrade complete");

// TODO remove this after upgrade
mutate_state(|state| state.data.principal_to_user_id_map.clear());
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ impl PrincipalToUserIdMap {
pub fn remove(&mut self, principal: &Principal) -> Option<UserId> {
self.map.remove(principal).map(|u| u.into())
}

pub fn clear(&mut self) {
self.map.clear_new()
}
}

fn init_map() -> StableBTreeMap<Principal, Principal, Memory> {
Expand Down

0 comments on commit a6a8c38

Please sign in to comment.