diff --git a/backend/canisters/user/impl/src/queries/get_cached_btc_address.rs b/backend/canisters/user/impl/src/queries/get_cached_btc_address.rs index 21102ff129..2270737fa8 100644 --- a/backend/canisters/user/impl/src/queries/get_cached_btc_address.rs +++ b/backend/canisters/user/impl/src/queries/get_cached_btc_address.rs @@ -4,7 +4,7 @@ use ic_cdk::query; use user_canister::get_cached_btc_address::{Response::*, *}; #[query(guard = "caller_is_owner")] -async fn get_cached_btc_address(_args: Args) -> Response { +fn get_cached_btc_address(_args: Args) -> Response { match read_state(|state| state.data.btc_address.clone()) { Some(btc_address) => Success(btc_address), None => NotFound, diff --git a/frontend/openchat-client/src/openchat.ts b/frontend/openchat-client/src/openchat.ts index bdbc0eb0ed..ce2df9dd91 100644 --- a/frontend/openchat-client/src/openchat.ts +++ b/frontend/openchat-client/src/openchat.ts @@ -780,6 +780,7 @@ export class OpenChat extends OpenChatAgentWorker { const durationUntilLogoutMs = durationUntilSessionExpireMS - ONE_MINUTE_MILLIS; // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; + function timeout() { console.debug( "SESSION: session has timed out after ", @@ -789,6 +790,7 @@ export class OpenChat extends OpenChatAgentWorker { ); self.logout().then(resolve); } + if (durationUntilLogoutMs <= 5 * ONE_MINUTE_MILLIS) { timeout(); } else { @@ -2330,6 +2332,7 @@ export class OpenChat extends OpenChatAgentWorker { await this.getMissingUsers(allUserIds); } + isTyping = isTyping; trackEvent = trackEvent; twitterLinkRegex = twitterLinkRegex; @@ -2393,6 +2396,7 @@ export class OpenChat extends OpenChatAgentWorker { ]); } } + blockCommunityUser(id: CommunityIdentifier, userId: string): Promise { this.blockCommunityUserLocally(id, userId); return this.sendRequest({ kind: "blockCommunityUser", id, userId }) @@ -2703,6 +2707,7 @@ export class OpenChat extends OpenChatAgentWorker { messageContentFromFile(file: File): Promise { return messageContentFromFile(file, this._liveState.isDiamond); } + formatFileSize = formatFileSize; haveCommunityPermissionsChanged(p1: CommunityPermissions, p2: CommunityPermissions): boolean { @@ -3143,6 +3148,7 @@ export class OpenChat extends OpenChatAgentWorker { return loadedUpTo < serverChat.latestEventIndex ? [loadedUpTo + 1, true] : undefined; } + private confirmedUpToEventIndex(chatId: ChatIdentifier): number | undefined { const ranges = confirmedEventIndexesLoaded(chatId).subranges(); if (ranges.length > 0) { @@ -3150,6 +3156,7 @@ export class OpenChat extends OpenChatAgentWorker { } return undefined; } + private confirmedThreadUpToEventIndex(): number | undefined { const ranges = get(confirmedThreadEventIndexesLoadedStore).subranges(); if (ranges.length > 0) { @@ -3234,6 +3241,7 @@ export class OpenChat extends OpenChatAgentWorker { unconfirmed.delete(context, messageId); messagesRead.removeUnconfirmedMessage(context, messageId); } + toggleProposalFilterMessageExpansion = toggleProposalFilterMessageExpansion; groupWhile = groupWhile; sameUser = sameUser; @@ -4938,12 +4946,19 @@ export class OpenChat extends OpenChatAgentWorker { if (userId === this._liveState.user.userId) return now; - let lastOnline = lastOnlineDates.get(userId, now); - if (lastOnline === undefined) { + const lastOnlineCached = lastOnlineDates.get(userId, now); + + const cacheValid = + lastOnlineCached !== undefined && + (lastOnlineCached.lastOnline < now - 5 * ONE_MINUTE_MILLIS || + lastOnlineCached.updated > now - 30 * 1000); + + if (cacheValid) { + return lastOnlineCached.lastOnline; + } else { const response = await this.getLastOnlineDatesBatched([userId]); - lastOnline = response[userId]; + return response[userId]; } - return lastOnline; } getPublicProfile(userId?: string): Promise { @@ -7139,6 +7154,7 @@ export class OpenChat extends OpenChatAgentWorker { // **** End of Communities stuff diamondDurationToMs = diamondDurationToMs; + swapRestricted(): Promise { return this.getUserLocation().then((location) => featureRestricted(location, "swap")); } diff --git a/frontend/openchat-client/src/stores/lastOnlineDates.ts b/frontend/openchat-client/src/stores/lastOnlineDates.ts index fd3f11523c..70f980f10c 100644 --- a/frontend/openchat-client/src/stores/lastOnlineDates.ts +++ b/frontend/openchat-client/src/stores/lastOnlineDates.ts @@ -18,9 +18,9 @@ function createLastOnlineDatesStore() { return { subscribe: store.subscribe, - get: (userId: string, now: number): number | undefined => { + get: (userId: string, now: number): LastOnline | undefined => { const value = storeValue.get(userId); - return value !== undefined && !expired(value, now) ? value.lastOnline : undefined; + return value !== undefined && !expired(value, now) ? value : undefined; }, set: (values: Iterable<[string, number]>, now: number): void => { store.update((map) => { @@ -31,7 +31,10 @@ function createLastOnlineDatesStore() { } } for (const [userId, lastOnline] of values) { - newMap.set(userId, { lastOnline, updated: now }); + const current = newMap.get(userId); + if (current === undefined || current.lastOnline < lastOnline) { + newMap.set(userId, { lastOnline, updated: now }); + } } return newMap; });