diff --git a/project.task.yaml b/project.task.yaml index 5a8b1cc..d111576 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -19,6 +19,7 @@ tasks : - .2 don't show a warning on a totally new project when the authorized agent is set - .2 anchor hash into BTC - .2 list the "show more" contacts alphabetically +- .5 add back the explicit wait for browser subscription timing problems? - .5 make Time Safari a share_target for images diff --git a/src/components/FeedFilters.vue b/src/components/FeedFilters.vue index 390205b..669e953 100644 --- a/src/components/FeedFilters.vue +++ b/src/components/FeedFilters.vue @@ -6,7 +6,10 @@

Show only activities that are…

-
+
From my contacts
@@ -14,7 +17,7 @@ @@ -27,11 +30,18 @@
-
+
Nearby
-
+
+
+ +
- -
+
+
@@ -81,6 +97,9 @@ import { LTileLayer, } from "@vue-leaflet/vue-leaflet"; +import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; +import { db } from "@/db/index"; + @Component({ components: { LRectangle, @@ -90,20 +109,80 @@ import { }, }) export default class FeedFilters extends Vue { - visible = false; - isFromMyContacts = false; + callOnCloseIfChanged = () => {}; + hasSearchBox = false; + isInMyContacts = false; isNearby = false; + settingChanged = false; + visible = false; + + async open(callOnCloseIfChanged: () => void) { + this.callOnCloseIfChanged = callOnCloseIfChanged; + + await db.open(); + const settings = await db.settings.get(MASTER_SETTINGS_KEY); + this.isInMyContacts = !!settings?.filterFeedContacts; + this.isNearby = !!settings?.filterFeedNearby; + if (settings?.searchBoxes && settings.searchBoxes.length > 0) { + this.hasSearchBox = true; + } - async open() { + this.settingChanged = false; this.visible = true; } + toggleContacts() { + this.settingChanged = true; + this.isInMyContacts = !this.isInMyContacts; + db.settings.update(MASTER_SETTINGS_KEY, { + filterFeedContacts: this.isInMyContacts, + }); + } + + toggleNearby() { + this.settingChanged = true; + this.isNearby = !this.isNearby; + db.settings.update(MASTER_SETTINGS_KEY, { + filterFeedNearby: this.isNearby, + }); + } + + async clearAll() { + if (this.isInMyContacts || this.isNearby) { + this.settingChanged = true; + } + + db.settings.update(MASTER_SETTINGS_KEY, { + filterFeedNearby: false, + filterFeedContacts: false, + }); + + this.isInMyContacts = false; + this.isNearby = false; + } + + async setAll() { + if (!this.isInMyContacts || !this.isNearby) { + this.settingChanged = true; + } + + db.settings.update(MASTER_SETTINGS_KEY, { + filterFeedNearby: true, + filterFeedContacts: true, + }); + + this.isInMyContacts = true; + this.isNearby = true; + } + close() { - // close the dialog but don't change values (just in case some actions are added later) + if (this.settingChanged) { + this.callOnCloseIfChanged(); + } this.visible = false; } - cancel() { + done() { this.close(); } } diff --git a/src/db/tables/settings.ts b/src/db/tables/settings.ts index f95b383..479ee63 100644 --- a/src/db/tables/settings.ts +++ b/src/db/tables/settings.ts @@ -16,6 +16,10 @@ export type Settings = { activeDid?: string; // Active Decentralized ID apiServer?: string; // API server URL + + filterFeedNearby?: string; // filter by nearby + filterFeedContacts?: string; // filter by user contacts + firstName?: string; // User's first name isRegistered?: boolean; lastName?: string; // deprecated - put all names in firstName diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index e6172ce..4194151 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -180,9 +180,9 @@

Latest Activity

@@ -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); } } diff --git a/src/views/SearchAreaView.vue b/src/views/SearchAreaView.vue index 4b3a750..e9c30e8 100644 --- a/src/views/SearchAreaView.vue +++ b/src/views/SearchAreaView.vue @@ -208,9 +208,9 @@ export default class DiscoverView extends Vue { group: "alert", type: "success", title: "Saved", - text: "That has been saved in your preferences.", + text: "That has been saved in your preferences. You can now filter by it on your home screen feed.", }, - -1, + 7000, ); this.$router.back(); } catch (err) { @@ -246,6 +246,7 @@ export default class DiscoverView extends Vue { await db.open(); db.settings.update(MASTER_SETTINGS_KEY, { searchBoxes: [], + filterFeedNearby: false, }); this.searchBox = null; this.localCenterLat = 0;