forked from jsnbuchanan/crowd-funder-for-time-pwa
filter by selections (now all working), add cache for plans
This commit is contained in:
@@ -3,21 +3,21 @@
|
||||
<div class="dialog">
|
||||
<h1 class="text-xl font-bold text-center mb-4">Feed Filters</h1>
|
||||
|
||||
<p class="mb-4 font-bold">Show only activities that are…</p>
|
||||
<p class="mb-4 font-bold">Show only activities that…</p>
|
||||
|
||||
<div class="grid grid-cols-1 gap-2">
|
||||
<div
|
||||
class="flex items-center justify-between cursor-pointer"
|
||||
@click="toggleContacts()"
|
||||
@click="toggleHasVisibleDid()"
|
||||
>
|
||||
<!-- label -->
|
||||
<div>From my contacts</div>
|
||||
<div>Include Someone Visible to Me</div>
|
||||
<!-- toggle -->
|
||||
<div class="relative ml-2">
|
||||
<!-- input -->
|
||||
<input
|
||||
type="checkbox"
|
||||
v-model="isInMyContacts"
|
||||
v-model="hasVisibleDid"
|
||||
name="toggleFilterFromMyContacts"
|
||||
class="sr-only"
|
||||
/>
|
||||
@@ -30,6 +30,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<em>or</em>
|
||||
|
||||
<div
|
||||
class="flex items-center justify-between cursor-pointer"
|
||||
@click="
|
||||
@@ -39,7 +41,7 @@
|
||||
"
|
||||
>
|
||||
<!-- label -->
|
||||
<div>Nearby</div>
|
||||
<div>Are Nearby</div>
|
||||
<!-- toggle -->
|
||||
<div v-if="hasSearchBox" class="relative ml-2">
|
||||
<!-- input -->
|
||||
@@ -109,20 +111,20 @@ import { db } from "@/db/index";
|
||||
},
|
||||
})
|
||||
export default class FeedFilters extends Vue {
|
||||
callOnCloseIfChanged = () => {};
|
||||
onCloseIfChanged = () => {};
|
||||
hasSearchBox = false;
|
||||
isInMyContacts = false;
|
||||
hasVisibleDid = false;
|
||||
isNearby = false;
|
||||
settingChanged = false;
|
||||
visible = false;
|
||||
|
||||
async open(callOnCloseIfChanged: () => void) {
|
||||
this.callOnCloseIfChanged = callOnCloseIfChanged;
|
||||
async open(onCloseIfChanged: () => void) {
|
||||
this.onCloseIfChanged = onCloseIfChanged;
|
||||
|
||||
await db.open();
|
||||
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
||||
this.isInMyContacts = !!settings?.filterFeedContacts;
|
||||
this.isNearby = !!settings?.filterFeedNearby;
|
||||
this.hasVisibleDid = !!settings?.filterFeedByVisible;
|
||||
this.isNearby = !!settings?.filterFeedByNearby;
|
||||
if (settings?.searchBoxes && settings.searchBoxes.length > 0) {
|
||||
this.hasSearchBox = true;
|
||||
}
|
||||
@@ -131,11 +133,11 @@ export default class FeedFilters extends Vue {
|
||||
this.visible = true;
|
||||
}
|
||||
|
||||
toggleContacts() {
|
||||
toggleHasVisibleDid() {
|
||||
this.settingChanged = true;
|
||||
this.isInMyContacts = !this.isInMyContacts;
|
||||
this.hasVisibleDid = !this.hasVisibleDid;
|
||||
db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
filterFeedContacts: this.isInMyContacts,
|
||||
filterFeedByVisible: this.hasVisibleDid,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -143,41 +145,41 @@ export default class FeedFilters extends Vue {
|
||||
this.settingChanged = true;
|
||||
this.isNearby = !this.isNearby;
|
||||
db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
filterFeedNearby: this.isNearby,
|
||||
filterFeedByNearby: this.isNearby,
|
||||
});
|
||||
}
|
||||
|
||||
async clearAll() {
|
||||
if (this.isInMyContacts || this.isNearby) {
|
||||
if (this.hasVisibleDid || this.isNearby) {
|
||||
this.settingChanged = true;
|
||||
}
|
||||
|
||||
db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
filterFeedNearby: false,
|
||||
filterFeedContacts: false,
|
||||
filterFeedByNearby: false,
|
||||
filterFeedByVisible: false,
|
||||
});
|
||||
|
||||
this.isInMyContacts = false;
|
||||
this.hasVisibleDid = false;
|
||||
this.isNearby = false;
|
||||
}
|
||||
|
||||
async setAll() {
|
||||
if (!this.isInMyContacts || !this.isNearby) {
|
||||
if (!this.hasVisibleDid || !this.isNearby) {
|
||||
this.settingChanged = true;
|
||||
}
|
||||
|
||||
db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
filterFeedNearby: true,
|
||||
filterFeedContacts: true,
|
||||
filterFeedByNearby: true,
|
||||
filterFeedByVisible: true,
|
||||
});
|
||||
|
||||
this.isInMyContacts = true;
|
||||
this.hasVisibleDid = true;
|
||||
this.isNearby = true;
|
||||
}
|
||||
|
||||
close() {
|
||||
if (this.settingChanged) {
|
||||
this.callOnCloseIfChanged();
|
||||
this.onCloseIfChanged();
|
||||
}
|
||||
this.visible = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user