Compare commits
6 Commits
f0babc6f95
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| bbfcbfcae6 | |||
| cd2903c0df | |||
| d873d99b23 | |||
| 1a5392d942 | |||
| ef80c0910c | |||
| 6c641acdd3 |
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "💡",
|
"emoji": "💡",
|
||||||
"previous": "&eN6DNPpQUNhGvxneLuLPgsOXR6qyFZ7u+MAz0b4fa7k=.sha256"
|
"previous": "&FGkkfFLaEID3V4lUjPbgCOwgEvNXkcVkzs0zzwD/gQ8=.sha256"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
class="w3-flex w3-dark-gray w3-center"
|
class="w3-flex w3-dark-gray w3-center"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
id="scrollbox"
|
||||||
style="
|
style="
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
@@ -251,6 +252,7 @@
|
|||||||
index == 0 ? 'hidden' : 'visible';
|
index == 0 ? 'hidden' : 'visible';
|
||||||
document.getElementById('right').style.visibility =
|
document.getElementById('right').style.visibility =
|
||||||
index == slides.length - 1 ? 'hidden' : 'visible';
|
index == slides.length - 1 ? 'hidden' : 'visible';
|
||||||
|
document.getElementById('scrollbox').scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let dots = [...document.getElementsByClassName('dot')];
|
let dots = [...document.getElementsByClassName('dot')];
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&/flKW9HptO5lHG19rMwc4GT9rGBFiRqVD87VDbWvsgc=.sha256"
|
"previous": "&Gq9oYdYRgeFSi5TbP/K8xRFtRmcRFmKgnbsEgDzEDoE=.sha256"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -612,7 +612,7 @@ class TfElement extends LitElement {
|
|||||||
by_count.push({count: v.of, id: id});
|
by_count.push({count: v.of, id: id});
|
||||||
}
|
}
|
||||||
let reactions = this.load_recent_reactions();
|
let reactions = this.load_recent_reactions();
|
||||||
this.load_channels_latest(Object.keys(following));
|
let channels = this.load_channels_latest(Object.keys(following));
|
||||||
this.channels_unread = JSON.parse(
|
this.channels_unread = JSON.parse(
|
||||||
(await tfrpc.rpc.databaseGet('unread')) ?? '{}'
|
(await tfrpc.rpc.databaseGet('unread')) ?? '{}'
|
||||||
);
|
);
|
||||||
@@ -625,6 +625,7 @@ class TfElement extends LitElement {
|
|||||||
self.users = result;
|
self.users = result;
|
||||||
});
|
});
|
||||||
await reactions;
|
await reactions;
|
||||||
|
await channels;
|
||||||
this.whoami = whoami;
|
this.whoami = whoami;
|
||||||
this.loaded = whoami;
|
this.loaded = whoami;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -707,9 +708,7 @@ class TfElement extends LitElement {
|
|||||||
.following=${this.following}
|
.following=${this.following}
|
||||||
whoami=${this.whoami}
|
whoami=${this.whoami}
|
||||||
.users=${this.users}
|
.users=${this.users}
|
||||||
query=${this.hash?.startsWith('#q=')
|
query=${this.search_text()}
|
||||||
? decodeURIComponent(this.hash.substring(3))
|
|
||||||
: null}
|
|
||||||
></tf-tab-search>
|
></tf-tab-search>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -758,7 +757,7 @@ class TfElement extends LitElement {
|
|||||||
search_text.focus();
|
search_text.focus();
|
||||||
this.set_tab('search');
|
this.set_tab('search');
|
||||||
} else {
|
} else {
|
||||||
this.set_hash('#q=' + search_text.value);
|
this.set_hash('#q=' + encodeURIComponent(search_text.value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,6 +767,16 @@ class TfElement extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
search_text() {
|
||||||
|
if (this.hash.startsWith('#q=')) {
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(this.hash.substring('#q='.length));
|
||||||
|
} catch {
|
||||||
|
return this.hash.substring('#q='.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
@@ -784,6 +793,12 @@ class TfElement extends LitElement {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let tabs = html`
|
let tabs = html`
|
||||||
|
<style>
|
||||||
|
#search_text:focus {
|
||||||
|
float: none !important;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div
|
<div
|
||||||
class="w3-bar w3-theme-l1"
|
class="w3-bar w3-theme-l1"
|
||||||
style="position: static; top: 0; z-index: 10"
|
style="position: static; top: 0; z-index: 10"
|
||||||
@@ -832,7 +847,7 @@ class TfElement extends LitElement {
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
<button class="w3-bar-item w3-button w3-right" @click=${this.search}>🔍<span class="w3-hide-small">Search</span></button>
|
<button class="w3-bar-item w3-button w3-right" @click=${this.search}>🔍<span class="w3-hide-small">Search</span></button>
|
||||||
<input type="text" class=${'w3-input w3-bar-item w3-right w3-theme-d1' + (this.tab == 'search' ? ' w3-mobile' : ' w3-hide-small')} placeholder="keywords, @id, #channel" id="search_text" @keydown=${this.search_keydown}></input>
|
<input type="text" class=${'w3-input w3-bar-item w3-right w3-theme-d1' + (this.tab == 'search' ? ' w3-mobile' : ' w3-hide-small')} placeholder="keywords, @id, #channel" id="search_text" @keydown=${this.search_keydown} value=${this.search_text()}></input>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
let contents = this.guest
|
let contents = this.guest
|
||||||
|
|||||||
@@ -398,12 +398,19 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
make_messages_key() {
|
||||||
|
return JSON.stringify([
|
||||||
|
this.hash,
|
||||||
|
Object.keys(this.channels_latest ?? {}).filter((x) => x != '🔐'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
async load_messages() {
|
async load_messages() {
|
||||||
let start_time = new Date();
|
let start_time = new Date();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.loading++;
|
this.loading++;
|
||||||
let messages = [];
|
let messages = [];
|
||||||
let original_key = JSON.stringify([this.hash, this.channels_latest ?? {}]);
|
let original_key = this.make_messages_key();
|
||||||
try {
|
try {
|
||||||
if (this._messages_key !== original_key) {
|
if (this._messages_key !== original_key) {
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
@@ -429,7 +436,7 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
} finally {
|
} finally {
|
||||||
this.loading--;
|
this.loading--;
|
||||||
}
|
}
|
||||||
let current_key = JSON.stringify([this.hash, this.channels_latest ?? {}]);
|
let current_key = this.make_messages_key();
|
||||||
if (current_key === original_key) {
|
if (current_key === original_key) {
|
||||||
this.messages = this.merge_messages(this.messages, messages);
|
this.messages = this.merge_messages(this.messages, messages);
|
||||||
}
|
}
|
||||||
@@ -486,19 +493,17 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
render() {
|
render() {
|
||||||
if (
|
if (
|
||||||
!this.messages ||
|
!this.messages ||
|
||||||
this._messages_key !==
|
this._messages_key !== this.make_messages_key() ||
|
||||||
JSON.stringify([this.hash, this.channels_latest ?? {}]) ||
|
|
||||||
this._messages_following !== JSON.stringify(this.following) ||
|
this._messages_following !== JSON.stringify(this.following) ||
|
||||||
this._private_messages !==
|
(this.hash.startsWith('#🔐') &&
|
||||||
JSON.stringify([
|
this._private_messages !==
|
||||||
this.private_messages,
|
JSON.stringify([
|
||||||
this.grouped_private_messages,
|
this.private_messages,
|
||||||
]) ||
|
this.grouped_private_messages,
|
||||||
this._channels_latest !==
|
]))
|
||||||
JSON.stringify(Object.keys(this.channels_latest))
|
|
||||||
) {
|
) {
|
||||||
console.log(
|
console.log(
|
||||||
`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})`
|
`loading messages for ${this.whoami} (messages=${!this.messages},${this._messages_key != this.make_messages_key()} following=${this._messages_following !== JSON.stringify(this.following)}, 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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -428,18 +428,18 @@ class TfTabNewsElement extends LitElement {
|
|||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
id="show_sidebar"
|
style="width: 100%; max-width: 100%; white-space: nowrap; overflow: hidden"
|
||||||
class="w3-button w3-hide-large"
|
|
||||||
@click=${this.show_sidebar}
|
|
||||||
>
|
|
||||||
${this.unread_status()}☰
|
|
||||||
</div>
|
|
||||||
<span
|
|
||||||
style="display: inline-block; width: 100%; max-width: 100%; white-space: nowrap; overflow: hidden"
|
|
||||||
>
|
>
|
||||||
|
<button
|
||||||
|
id="show_sidebar"
|
||||||
|
class="w3-button w3-hide-large"
|
||||||
|
@click=${this.show_sidebar}
|
||||||
|
>
|
||||||
|
${this.unread_status()}☰
|
||||||
|
</button>
|
||||||
Welcome,
|
Welcome,
|
||||||
<tf-user id=${this.whoami} .users=${this.users}></tf-user>!
|
<tf-user id=${this.whoami} .users=${this.users}></tf-user>!
|
||||||
</span>
|
</div>
|
||||||
${edit_profile}
|
${edit_profile}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -44,36 +44,37 @@ class TfTabSearchElement extends LitElement {
|
|||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
this.results = [];
|
this.results = [];
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
if (query.startsWith('sql:')) {
|
try {
|
||||||
this.messages = [];
|
if (query.startsWith('sql:')) {
|
||||||
try {
|
this.messages = [];
|
||||||
this.results = await tfrpc.rpc.query(
|
this.results = await tfrpc.rpc.query(
|
||||||
query.substring('sql:'.length),
|
query.substring('sql:'.length),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} else {
|
||||||
this.results = [];
|
let results = await tfrpc.rpc.query(
|
||||||
this.error = e;
|
`
|
||||||
|
SELECT messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
|
FROM messages_fts(?)
|
||||||
|
JOIN messages ON messages.rowid = messages_fts.rowid
|
||||||
|
JOIN json_each(?) AS following ON messages.author = following.value
|
||||||
|
ORDER BY timestamp DESC limit 100
|
||||||
|
`,
|
||||||
|
['"' + query.replace('"', '""') + '"', JSON.stringify(this.following)]
|
||||||
|
);
|
||||||
|
search = this.renderRoot.getElementById('search');
|
||||||
|
if (search) {
|
||||||
|
search.value = query;
|
||||||
|
search.focus();
|
||||||
|
search.select();
|
||||||
|
}
|
||||||
|
this.messages = results;
|
||||||
}
|
}
|
||||||
} else {
|
} catch (e) {
|
||||||
let results = await tfrpc.rpc.query(
|
this.messages = [];
|
||||||
`
|
this.results = [];
|
||||||
SELECT messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
this.error = e;
|
||||||
FROM messages_fts(?)
|
console.log(e);
|
||||||
JOIN messages ON messages.rowid = messages_fts.rowid
|
|
||||||
JOIN json_each(?) AS following ON messages.author = following.value
|
|
||||||
ORDER BY timestamp DESC limit 100
|
|
||||||
`,
|
|
||||||
['"' + query.replace('"', '""') + '"', JSON.stringify(this.following)]
|
|
||||||
);
|
|
||||||
console.log('Done.');
|
|
||||||
search = this.renderRoot.getElementById('search');
|
|
||||||
if (search) {
|
|
||||||
search.value = query;
|
|
||||||
search.focus();
|
|
||||||
search.select();
|
|
||||||
}
|
|
||||||
this.messages = results;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ class TfUserElement extends LitElement {
|
|||||||
name = this.icon_only
|
name = this.icon_only
|
||||||
? undefined
|
? undefined
|
||||||
: !this.nolink
|
: !this.nolink
|
||||||
? html`<a target="_top" href=${'#' + this.id}>${name_string}</a>`
|
? html`<a target="_top" href=${'#' + encodeURIComponent(this.id)}
|
||||||
|
>${name_string}</a
|
||||||
|
>`
|
||||||
: html`<span>${name_string}</span>`;
|
: html`<span>${name_string}</span>`;
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
|
|||||||
Reference in New Issue
Block a user