minor tweaks:

- add padding to markdown <p> in story mode, fixing #6?
- fix page sorting: switch to best match if searching, otherwise default to date
This commit is contained in:
Ilya Kreymer
2020-09-06 17:10:48 -07:00
parent 2212678ed7
commit a3214dc081
4 changed files with 53 additions and 36 deletions
+19 -8
View File
@@ -15,10 +15,9 @@ class Sorter extends LitElement
this.data = [];
this.numResults = DEFAULT_RESULTS;
this.defaultDesc = false;
this.sortKey = "url";
this.sortDesc = false;
this.sortKey = null;
this.sortDesc = null;
this.defaultKey = "";
this.defaultDesc = false;
@@ -41,11 +40,15 @@ class Sorter extends LitElement
}
}
firstUpdated() {
this.sortKey = localStorage.getItem(`${this.id}:sortKey`) || this.defaultKey;
const sortDesc = localStorage.getItem(`${this.id}:sortDesc`);
this.sortDesc = !sortDesc ? this.defaultDesc : sortDesc === "1";
}
// firstUpdated() {
// if (this.sortKey === null && this.defaultKey) {
// this.sortKey = localStorage.getItem(`${this.id}:sortKey`) || this.defaultKey;
// }
// const sortDesc = localStorage.getItem(`${this.id}:sortDesc`);
// if (this.sortDesc === null) {
// this.sortDesc = !sortDesc ? this.defaultDesc : sortDesc === "1";
// }
// }
updated(changedProperties) {
const keyChanged = changedProperties.has("sortKey");
@@ -53,6 +56,14 @@ class Sorter extends LitElement
const dataChanged = changedProperties.has("data");
const numResultsChanged = changedProperties.has("numResults");
if (changedProperties.has("defaultKey")) {
this.sortKey = this.defaultKey;
}
if (changedProperties.has("defaultDesc")) {
this.sortDesc = this.defaultDesc;
}
if (keyChanged) {
localStorage.setItem(`${this.id}:sortKey`, this.sortKey);
}