core: Refresh identity info so that you see your name at the top right when editing your profile in ssb.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 9m34s

This commit is contained in:
2025-11-16 13:40:50 -05:00
parent bb52cdd7c2
commit 98f7504a4c
2 changed files with 61 additions and 21 deletions

View File

@@ -17,6 +17,8 @@ let gProcesses = {};
let gStatsTimer = false;
/** Effectively a process ID. */
let g_handler_index = 0;
/** Whether updating accounts information is currently scheduled. */
let g_update_accounts_scheduled;
/** Time between pings, in milliseconds. */
const k_ping_interval = 60 * 1000;
@@ -275,18 +277,23 @@ async function getProcessBlob(blobId, key, options) {
},
};
process.sendIdentities = async function () {
process.app.send(
Object.assign(
{
action: 'identities',
},
await ssb_internal.getIdentityInfo(
process?.credentials?.session?.name,
options?.packageOwner,
options?.packageName
)
)
let identities = await ssb_internal.getIdentityInfo(
process?.credentials?.session?.name,
options?.packageOwner,
options?.packageName
);
let json = JSON.stringify(identities);
if (process._last_sent_identities !== json) {
process.app.send(
Object.assign(
{
action: 'identities',
},
identities
)
);
process._last_sent_identities = json;
}
};
process.setActiveIdentity = async function (identity) {
if (
@@ -624,11 +631,27 @@ async function getProcessBlob(blobId, key, options) {
return process;
}
/**
* Send any changed account information.
*/
function updateAccounts() {
let promises = [];
for (let process of Object.values(gProcesses)) {
promises.push(process.sendIdentities());
}
return Promise.all(promises);
}
/**
* SSB message added callback.
*/
ssb_internal.addEventListener('message', function () {
broadcastEvent('onMessage', [...arguments]);
if (!g_update_accounts_scheduled) {
setTimeout(updateAccounts, 1000);
g_update_accounts_scheduled = true;
}
});
ssb_internal.addEventListener('blob', function () {