forked from cory/tildefriends
Hitting some limit with following too many people. Working around it.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4610 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
6ef14d985d
commit
aa10ab69f6
@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "🐌",
|
||||
"previous": "&qvm+scemENl4DobpOoh/UyILGvvx5NbcPJKTU3CswSE=.sha256"
|
||||
"previous": "&tx4iQew0sHvZW3YAEx8y2Qr8m+MhoNdxs/5+1Rx4s7Y=.sha256"
|
||||
}
|
@ -212,8 +212,8 @@ class TfElement extends LitElement {
|
||||
let whoami = this.whoami;
|
||||
let tags = this.load_recent_tags();
|
||||
let following = await tfrpc.rpc.following([whoami], 2);
|
||||
console.log(following);
|
||||
let users = {};
|
||||
let by_count = [];
|
||||
for (let [id, v] of Object.entries(following)) {
|
||||
users[id] = {
|
||||
following: v.of,
|
||||
@ -221,7 +221,9 @@ class TfElement extends LitElement {
|
||||
followed: v.if,
|
||||
blocked: v.ib,
|
||||
};
|
||||
by_count.push({count: v.of, id: id});
|
||||
}
|
||||
console.log(by_count.sort((x, y) => y.count - x.count).slice(0, 20));
|
||||
users = await this.fetch_about(Object.keys(following).sort(), users);
|
||||
this.following = Object.keys(following);
|
||||
this.users = users;
|
||||
|
@ -65,7 +65,10 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
this.hash.substring(1),
|
||||
]);
|
||||
} else {
|
||||
return await tfrpc.rpc.query(
|
||||
let messages = [];
|
||||
const k_following_limit = 2048;
|
||||
for (let i = 0; i < this.following.length; i += k_following_limit) {
|
||||
messages = messages.concat(await tfrpc.rpc.query(
|
||||
`
|
||||
WITH news AS (SELECT messages.*
|
||||
FROM messages
|
||||
@ -85,14 +88,16 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
SELECT news.* FROM news
|
||||
`,
|
||||
[
|
||||
JSON.stringify(this.following),
|
||||
JSON.stringify(this.following.slice(i, i + k_following_limit)),
|
||||
this.start_time,
|
||||
/*
|
||||
** Don't show messages more than a day into the future to prevent
|
||||
** messages with far-future timestamps from staying at the top forever.
|
||||
*/
|
||||
new Date().valueOf() + 24 * 60 * 60 * 1000,
|
||||
]);
|
||||
]));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,6 +133,7 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
}
|
||||
|
||||
async decrypt(messages) {
|
||||
console.log('decrypt');
|
||||
let result = [];
|
||||
for (let message of messages) {
|
||||
let content;
|
||||
@ -162,7 +168,7 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
if (!this.messages ||
|
||||
this._messages_hash !== this.hash ||
|
||||
this._messages_following !== this.following) {
|
||||
console.log(`loading messages for ${this.whoami}`);
|
||||
console.log(`loading messages for ${this.whoami} (following ${this.following.length})`);
|
||||
let self = this;
|
||||
this.messages = [];
|
||||
this._messages_hash = this.hash;
|
||||
|
Loading…
Reference in New Issue
Block a user