Skip to content

Commit

Permalink
renaming vars
Browse files Browse the repository at this point in the history
  • Loading branch information
boonboonsiri committed Dec 18, 2023
1 parent 31da5cd commit eb91891
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SearchAPI {
layers,
countryCode,
expandUnits,
session,
sessionToken,
} = params;

// near can be provided as a string or Location object
Expand All @@ -44,7 +44,7 @@ class SearchAPI {
layers,
countryCode,
expandUnits,
session,
sessionToken,
},
});

Expand All @@ -61,7 +61,7 @@ class SearchAPI {

static async autocompleteSelect(params: RadarAutocompleteSessionSelectionParams) {
await Http.request({
method: 'GET',
method: 'POST',
path: 'search/autocomplete/selection',
data: {
...params
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,12 @@ export interface RadarAutocompleteParams {
layers?: RadarGeocodeLayer[];
countryCode?: string;
expandUnits?: boolean;
session?: string;
sessionToken?: string;
}

export interface RadarAutocompleteSessionSelectionParams {
session: string;
selection: number;
sessionToken: string;
selectionIndex: number;
radarSessionId?: string;
userId?: string;
deviceId?: string;
Expand Down
20 changes: 9 additions & 11 deletions src/ui/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import Storage from '../storage';
import { RadarAutocompleteContainerNotFound } from '../errors';
import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location, RadarAutocompleteSessionSelectionParams } from '../types';

import crypto from 'crypto';

const CLASSNAMES = {
WRAPPER: 'radar-autocomplete-wrapper',
INPUT: 'radar-autocomplete-input',
Expand Down Expand Up @@ -91,7 +89,7 @@ class AutocompleteUI {
resultsList: HTMLElement;
wrapper: HTMLElement;
poweredByLink?: HTMLElement;
session?: string;
sessionToken?: string;
autocompleteParams?: RadarAutocompleteParams;

// create a new AutocompleteUI instance
Expand Down Expand Up @@ -245,18 +243,18 @@ class AutocompleteUI {
public async fetchResults(query: string) {
const { limit, layers, countryCode, expandUnits, onRequest } = this.config;

if (!this.session) {
this.session = this.generateUUID();
if (!this.sessionToken) {
this.sessionToken = this.generateUUID();
}
const session = this.session;
const sessionToken = this.sessionToken;

const params: RadarAutocompleteParams = {
query,
limit,
layers,
countryCode,
expandUnits,
session,
sessionToken,
}

if (this.near) {
Expand Down Expand Up @@ -458,14 +456,14 @@ class AutocompleteUI {
}

// Radar Autocomplete Session
if (this.session) {
if (this.sessionToken) {
const userId = Storage.getItem(Storage.USER_ID) || undefined;
const deviceId = Device.getDeviceId() || undefined;
const installId = Device.getInstallId() || undefined;
const radarSessionId = Session.getSessionId() || undefined;
const params: RadarAutocompleteSessionSelectionParams = {
session: this.session,
selection: index,
sessionToken: this.sessionToken,
selectionIndex: index,
userId,
deviceId,
installId,
Expand All @@ -476,7 +474,7 @@ class AutocompleteUI {
}

// Close out session
this.session = undefined;
this.sessionToken = undefined;
this.autocompleteParams = undefined;

// clear results list
Expand Down

0 comments on commit eb91891

Please sign in to comment.