feed filter: save the changed values to the DB, go to map if no location chosen, reload if necessary

This commit is contained in:
2024-04-03 19:54:01 -06:00
parent 027825b155
commit e3696e3ac5
5 changed files with 129 additions and 24 deletions

View File

@@ -180,9 +180,9 @@
<h2 class="text-xl font-bold">Latest Activity</h2>
<button
@click="openFeedFilters()"
class="block text-center text-sm uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-1.5 ml-auto rounded-md"
class="block text-center text-sm uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-1.5 ml-auto rounded-md"
>
Filter
{{ resultsAreFiltered() ? "Filtered" : "Unfiltered" }}
</button>
</div>
<InfiniteScroll @reached-bottom="loadMoreGives">
@@ -311,6 +311,8 @@ export default class HomeView extends Vue {
feedPreviousOldestId?: string;
feedLastViewedClaimId?: string;
isCreatingIdentifier = false;
isFeedFilteredByContacts = false;
isFeedFilteredByNearby = false;
isFeedLoading = true;
isRegistered = false;
showShortcutBvc = false;
@@ -335,7 +337,7 @@ export default class HomeView extends Vue {
return headers;
}
async created() {
async mounted() {
try {
await accountsDB.open();
const allAccounts = await accountsDB.accounts.toArray();
@@ -347,6 +349,8 @@ export default class HomeView extends Vue {
this.activeDid = settings?.activeDid || "";
this.allContacts = await db.contacts.toArray();
this.feedLastViewedClaimId = settings?.lastViewedClaimId;
this.isFeedFilteredByContacts = !!settings?.filterFeedContacts;
this.isFeedFilteredByNearby = !!settings?.filterFeedNearby;
this.isRegistered = !!settings?.isRegistered;
this.showShortcutBvc = !!settings?.showShortcutBvc;
@@ -378,6 +382,10 @@ export default class HomeView extends Vue {
}
}
resultsAreFiltered() {
return this.isFeedFilteredByContacts || this.isFeedFilteredByNearby;
}
notificationsSupported() {
return "Notification" in window;
}
@@ -408,6 +416,18 @@ export default class HomeView extends Vue {
return headers;
}
// only called when a setting was changed
async reloadFeedOnChange() {
await db.open();
const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings;
this.isFeedFilteredByContacts = !!settings?.filterFeedContacts;
this.isFeedFilteredByNearby = !!settings?.filterFeedNearby;
this.feedData = [];
this.feedPreviousOldestId = undefined;
this.updateAllFeed();
}
/**
* Data loader used by infinite scroller
* @param payload is the flag from the InfiniteScroll indicating if it should load
@@ -587,7 +607,7 @@ export default class HomeView extends Vue {
}
openFeedFilters() {
(this.$refs.feedFilters as FeedFilters).open();
(this.$refs.feedFilters as FeedFilters).open(this.reloadFeedOnChange);
}
}
</script>