Browse Source

fix the result count when the search filters change

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

19
src/views/DiscoverView.vue

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

Loading…
Cancel
Save