Cache: Slight optimization (#4947)
This commit is contained in:
parent
875609f0d8
commit
a7ecd74fa4
@ -259,10 +259,10 @@ function updateCache(force?: boolean) {
|
|||||||
export function forceUpdateCache(noEncrypt = false) {
|
export function forceUpdateCache(noEncrypt = false) {
|
||||||
const global = getGlobal();
|
const global = getGlobal();
|
||||||
const { hasPasscode, isScreenLocked } = global.passcode;
|
const { hasPasscode, isScreenLocked } = global.passcode;
|
||||||
const serializedGlobal = serializeGlobal(global);
|
|
||||||
|
|
||||||
if (hasPasscode) {
|
if (hasPasscode) {
|
||||||
if (!isScreenLocked && !noEncrypt) {
|
if (!isScreenLocked && !noEncrypt) {
|
||||||
|
const serializedGlobal = serializeGlobal(global);
|
||||||
void encryptSession(undefined, serializedGlobal);
|
void encryptSession(undefined, serializedGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,9 +390,9 @@ function reduceUsers<T extends GlobalState>(global: T): GlobalState['users'] {
|
|||||||
]).slice(0, GLOBAL_STATE_CACHE_USER_LIST_LIMIT);
|
]).slice(0, GLOBAL_STATE_CACHE_USER_LIST_LIMIT);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
byId: pick(byId, idsToSave),
|
byId: pickTruthy(byId, idsToSave),
|
||||||
statusesById: pick(statusesById, idsToSave),
|
statusesById: pickTruthy(statusesById, idsToSave),
|
||||||
fullInfoById: pick(fullInfoById, idsToSave),
|
fullInfoById: pickTruthy(fullInfoById, idsToSave),
|
||||||
previewMediaByBotId: {},
|
previewMediaByBotId: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -436,10 +436,10 @@ function reduceChats<T extends GlobalState>(global: T): GlobalState['chats'] {
|
|||||||
...global.chats,
|
...global.chats,
|
||||||
similarChannelsById: {},
|
similarChannelsById: {},
|
||||||
isFullyLoaded: {},
|
isFullyLoaded: {},
|
||||||
byId: pick(global.chats.byId, idsToSave),
|
byId: pickTruthy(global.chats.byId, idsToSave),
|
||||||
fullInfoById: pick(global.chats.fullInfoById, idsToSave),
|
fullInfoById: pickTruthy(global.chats.fullInfoById, idsToSave),
|
||||||
lastMessageIds: {
|
lastMessageIds: {
|
||||||
all: pick(global.chats.lastMessageIds.all || {}, idsToSave),
|
all: pickTruthy(global.chats.lastMessageIds.all || {}, idsToSave),
|
||||||
saved: global.chats.lastMessageIds.saved,
|
saved: global.chats.lastMessageIds.saved,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user