abmp-npm 2.0.61 → 2.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abmp-npm",
3
- "version": "2.0.61",
3
+ "version": "2.0.62",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "check-cycles": "madge --circular .",
@@ -5,37 +5,7 @@ const { DEFAULT_FILTER } = require('../consts.js');
5
5
 
6
6
  const { debouncedFunction } = require('./sharedUtils.js');
7
7
 
8
- /** Returned when an in-flight search was superseded; do not apply results to UI */
9
- const STALE_SEARCH_RESPONSE = Symbol('STALE_SEARCH_RESPONSE');
10
-
11
- function generateSearchId() {
12
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
13
- const r = (Math.random() * 16) | 0;
14
- const v = c === 'x' ? r : (r & 0x3) | 0x8;
15
- return v.toString(16);
16
- });
17
- }
18
-
19
8
  const createHomepageUtils = (_$w, filterProfiles) => {
20
- let currentSearchId = null;
21
-
22
- async function fetchProfilesWithSearchId(args) {
23
- const thisSearchId = generateSearchId();
24
- currentSearchId = thisSearchId;
25
- try {
26
- const response = await filterProfiles(args);
27
- if (thisSearchId !== currentSearchId) {
28
- return STALE_SEARCH_RESPONSE;
29
- }
30
- return response;
31
- } catch (error) {
32
- if (thisSearchId !== currentSearchId) {
33
- return STALE_SEARCH_RESPONSE;
34
- }
35
- throw error;
36
- }
37
- }
38
-
39
9
  const getFiltersSelectors = filterName => ({
40
10
  checkBoxContainerSelector: _$w(`#${filterName}CheckBoxContainer`),
41
11
  searchTextInputSelector: _$w(`#${filterName}TextInput`),
@@ -717,10 +687,7 @@ const createHomepageUtils = (_$w, filterProfiles) => {
717
687
  }
718
688
  const nonDebouncedFilterProfiles = async () => {
719
689
  try {
720
- const result = await fetchProfilesWithSearchId({ filter, isSearchingNearby });
721
- if (result === STALE_SEARCH_RESPONSE) {
722
- return { success: true, response: STALE_SEARCH_RESPONSE };
723
- }
690
+ const result = await filterProfiles({ filter, isSearchingNearby });
724
691
  return { success: true, response: result };
725
692
  } catch (error) {
726
693
  return { success: false, error };
@@ -732,15 +699,12 @@ const createHomepageUtils = (_$w, filterProfiles) => {
732
699
  ? () => nonDebouncedFilterProfiles()
733
700
  : () =>
734
701
  debouncedFunction({
735
- func: fetchProfilesWithSearchId,
702
+ func: filterProfiles,
736
703
  debounceTimeout,
737
704
  timeoutType,
738
705
  args: { filter, isSearchingNearby },
739
706
  });
740
707
  const { success, response, error } = await funcPromise();
741
- if (response === STALE_SEARCH_RESPONSE) {
742
- return [];
743
- }
744
708
  if (!success) {
745
709
  _$w('#numberOfResults').text = '';
746
710
  console.error('[search] failed with error:', error);