diff --git a/apps/ssb.json b/apps/ssb.json
index 43108958..fe991592 100644
--- a/apps/ssb.json
+++ b/apps/ssb.json
@@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🦀",
- "previous": "&+/LuVOJUXuNSQRUD8PSgGzOdsWx47TPDcyUef5An2JQ=.sha256"
+ "previous": "&KPnjURiuJa5b0ONjxz11bMm7yuhY9wlBTyB+fzl0zzk=.sha256"
}
diff --git a/apps/ssb/tf-app.js b/apps/ssb/tf-app.js
index 0533af52..32fe3d26 100644
--- a/apps/ssb/tf-app.js
+++ b/apps/ssb/tf-app.js
@@ -707,9 +707,7 @@ class TfElement extends LitElement {
.following=${this.following}
whoami=${this.whoami}
.users=${this.users}
- query=${this.hash?.startsWith('#q=')
- ? decodeURIComponent(this.hash.substring(3))
- : null}
+ query=${this.search_text()}
>
`;
}
@@ -758,7 +756,7 @@ class TfElement extends LitElement {
search_text.focus();
this.set_tab('search');
} else {
- this.set_hash('#q=' + search_text.value);
+ this.set_hash('#q=' + encodeURIComponent(search_text.value));
}
}
@@ -768,6 +766,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() {
let self = this;
@@ -832,7 +840,7 @@ class TfElement extends LitElement {
: undefined
}
-
+
`;
let contents = this.guest
diff --git a/apps/ssb/tf-tab-search.js b/apps/ssb/tf-tab-search.js
index 96113cf1..fd2d9cc5 100644
--- a/apps/ssb/tf-tab-search.js
+++ b/apps/ssb/tf-tab-search.js
@@ -44,36 +44,37 @@ class TfTabSearchElement extends LitElement {
this.error = undefined;
this.results = [];
this.messages = [];
- if (query.startsWith('sql:')) {
- this.messages = [];
- try {
+ try {
+ if (query.startsWith('sql:')) {
+ this.messages = [];
this.results = await tfrpc.rpc.query(
query.substring('sql:'.length),
[]
);
- } catch (e) {
- this.results = [];
- this.error = e;
+ } else {
+ let results = await tfrpc.rpc.query(
+ `
+ 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 {
- let results = await tfrpc.rpc.query(
- `
- 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)]
- );
- console.log('Done.');
- search = this.renderRoot.getElementById('search');
- if (search) {
- search.value = query;
- search.focus();
- search.select();
- }
- this.messages = results;
+ } catch (e) {
+ this.messages = [];
+ this.results = [];
+ this.error = e;
+ console.log(e);
}
}
diff --git a/apps/ssb/tf-user.js b/apps/ssb/tf-user.js
index da7a3e92..69030b8d 100644
--- a/apps/ssb/tf-user.js
+++ b/apps/ssb/tf-user.js
@@ -39,7 +39,9 @@ class TfUserElement extends LitElement {
name = this.icon_only
? undefined
: !this.nolink
- ? html`${name_string}`
+ ? html`${name_string}`
: html`${name_string}`;
if (user) {