forked from cory/tildefriends
ssb: Reduce redundant queries.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&h2f5ZDN1srctuCbTXvXbNwcs2KnRDbk10DlIdZePnXo=.sha256"
|
"previous": "&k075s5Ij+NjRS52GJ6AD8Pl2ZGNseuj63AKBeV4LMQg=.sha256"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ class TfElement extends LitElement {
|
|||||||
),
|
),
|
||||||
])
|
])
|
||||||
).flat();
|
).flat();
|
||||||
let latest = {};
|
let latest = {'🔐': undefined};
|
||||||
for (let row of channels) {
|
for (let row of channels) {
|
||||||
if (!latest[row.channel]) {
|
if (!latest[row.channel]) {
|
||||||
latest[row.channel] = row.rowid;
|
latest[row.channel] = row.rowid;
|
||||||
@@ -506,14 +506,13 @@ class TfElement extends LitElement {
|
|||||||
let self = this;
|
let self = this;
|
||||||
start_time = new Date();
|
start_time = new Date();
|
||||||
latest_private.then(async function (latest) {
|
latest_private.then(async function (latest) {
|
||||||
|
let grouped = await self.group_private_messages(latest[1]);
|
||||||
self.channels_latest = Object.assign({}, self.channels_latest, {
|
self.channels_latest = Object.assign({}, self.channels_latest, {
|
||||||
'🔐': latest[0],
|
'🔐': latest[0],
|
||||||
});
|
});
|
||||||
console.log('private took', (new Date() - start_time) / 1000.0);
|
|
||||||
self.private_messages = latest[1];
|
self.private_messages = latest[1];
|
||||||
self.grouped_private_messages = await self.group_private_messages(
|
self.grouped_private_messages = grouped;
|
||||||
latest[1]
|
console.log('private took', (new Date() - start_time) / 1000.0);
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -395,9 +395,10 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
this._messages_hash = this.hash;
|
this._messages_hash = this.hash;
|
||||||
}
|
}
|
||||||
this._messages_following = JSON.stringify(this.following);
|
this._messages_following = JSON.stringify(this.following);
|
||||||
this._private_messages =
|
this._private_messages = JSON.stringify([
|
||||||
JSON.stringify(this.private_messages) +
|
this.private_messages,
|
||||||
JSON.stringify(this.grouped_private_messages);
|
this.grouped_private_messages,
|
||||||
|
]);
|
||||||
this._channels_latest = JSON.stringify(
|
this._channels_latest = JSON.stringify(
|
||||||
Object.keys(this.channels_latest ?? {})
|
Object.keys(this.channels_latest ?? {})
|
||||||
);
|
);
|
||||||
@@ -475,13 +476,15 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
this._messages_hash !== this.hash ||
|
this._messages_hash !== this.hash ||
|
||||||
this._messages_following !== JSON.stringify(this.following) ||
|
this._messages_following !== JSON.stringify(this.following) ||
|
||||||
this._private_messages !==
|
this._private_messages !==
|
||||||
JSON.stringify(this.private_messages) +
|
JSON.stringify([
|
||||||
JSON.stringify(this.grouped_private_messages) ||
|
this.private_messages,
|
||||||
|
this.grouped_private_messages,
|
||||||
|
]) ||
|
||||||
this._channels_latest !==
|
this._channels_latest !==
|
||||||
JSON.stringify(Object.keys(this.channels_latest))
|
JSON.stringify(Object.keys(this.channels_latest))
|
||||||
) {
|
) {
|
||||||
console.log(
|
console.log(
|
||||||
`loading messages for ${this.whoami} (following ${this.following.length})`
|
`loading messages for ${this.whoami} (messages=${!this.messages},${this._messages_hash != this.hash} following=${this._messages_following !== JSON.stringify(this.following)}, channels=${this._channels_latest !== JSON.stringify(Object.keys(this.channels_latest))}, private=${this._private_messages !== JSON.stringify([this.private_messages, this.grouped_private_messages])},${this.private_messages?.length},${Object.keys(this.grouped_private_messages ?? {}).length})`
|
||||||
);
|
);
|
||||||
this.load_messages();
|
this.load_messages();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,7 +337,10 @@ async function getProcessBlob(blobId, key, options) {
|
|||||||
};
|
};
|
||||||
if (process.credentials?.permissions?.administration) {
|
if (process.credentials?.permissions?.administration) {
|
||||||
imports.core.globalSettingsSet = async function (key, value) {
|
imports.core.globalSettingsSet = async function (key, value) {
|
||||||
await imports.core.permissionTest('set_global_setting', `Set ${JSON.stringify(key)} to ${JSON.stringify(value)}.`);
|
await imports.core.permissionTest(
|
||||||
|
'set_global_setting',
|
||||||
|
`Set ${JSON.stringify(key)} to ${JSON.stringify(value)}.`
|
||||||
|
);
|
||||||
print('Setting', key, value);
|
print('Setting', key, value);
|
||||||
let settings = await loadSettings();
|
let settings = await loadSettings();
|
||||||
settings[key] = value;
|
settings[key] = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user