Skip to content

Commit

Permalink
add todo comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Nov 26, 2018
1 parent 2bc8766 commit 24cdbc6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/PackageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import Package from '../../types/Package';
import { EventBus, Events } from '@/services/event-bus';
import LoadingSpinner from '@/components/LoadingSpinner.vue';
import CrafterAvatar from '@/components/CrafterAvatar.vue';
import Searchable from '../../types/Searchable';
@Component({
components: {
Expand Down Expand Up @@ -80,13 +81,16 @@ export default class Packages extends Vue {
this.loadConfig();
EventBus.$on(Events.FILTER_SEARCH, async ({filters, query}) => {
// TODO: refactor this (#14)
EventBus.$on(Events.FILTER_SEARCH, async ( args: { filters: Searchable[], query: string} ) => {
this.packages.all = await DataStore.Instance.getPackages();
this.packages.data = this.packages.all.filter((item) => filters.indexOf(item) >= 0).filter((item) => {
if (!query) {
this.packages.data = this.packages.all
.filter((item) => args.filters.indexOf(item) >= 0)
.filter((item) => {
if (!args.query) {
return true;
}
const pattern = new RegExp(query.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, ''), 'gi');
const pattern = new RegExp(args.query.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, ''), 'gi');
const someCrafterMatches = item.crafters.some((crafter) => {
if (
crafter.name &&
Expand Down

0 comments on commit 24cdbc6

Please sign in to comment.