Browse Source

fix the result count when the search filters change

searching
Trent Larson 12 months ago
parent
commit
606d9ec734
  1. 19
      src/views/DiscoverView.vue

19
src/views/DiscoverView.vue

@ -41,8 +41,10 @@
Nearby
<span
class="font-semibold text-sm bg-slate-200 px-1.5 py-0.5 rounded-md"
>{{ localCount > -1 ? localCount : "?" }}</span
v-if="isLocalActive"
>
{{ localCount > -1 ? localCount : "?" }}
</span>
</a>
</li>
<li>
@ -59,8 +61,10 @@
Anywhere
<span
class="font-semibold text-sm bg-slate-200 px-1.5 py-0.5 rounded-md"
>{{ remoteCount > -1 ? remoteCount : "?" }}</span
v-if="isRemoteActive"
>
{{ remoteCount > -1 ? remoteCount : "?" }}
</span>
</a>
</li>
</ul>
@ -156,12 +160,12 @@ export default class DiscoverView extends Vue {
apiServer = "";
searchTerms = "";
projects: ProjectData[] = [];
isLoading = false;
isLocalActive = true;
isRemoteActive = false;
localCount = -1;
remoteCount = -1;
searchBox: { name: string; bbox: BoundingBox } | null = null;
isLoading = false;
// make this function available to the Vue template
didInfo = didInfo;
@ -188,6 +192,11 @@ export default class DiscoverView extends Vue {
}
}
public resetCounts() {
this.localCount = -1;
this.remoteCount = -1;
}
public async searchSelected() {
if (this.isLocalActive) {
await this.searchLocal();
@ -221,6 +230,8 @@ export default class DiscoverView extends Vue {
}
public async searchAll(beforeId?: string) {
this.resetCounts();
if (!beforeId) {
// this was an initial search so clear any previous results
this.projects = [];
@ -288,6 +299,8 @@ export default class DiscoverView extends Vue {
}
public async searchLocal(beforeId?: string) {
this.resetCounts();
if (!this.searchBox) {
this.projects = [];
return;

Loading…
Cancel
Save