Skip to content

Commit

Permalink
fix(client): small fixes to various parts of the client
Browse files Browse the repository at this point in the history
  • Loading branch information
KenEucker committed Dec 15, 2023
1 parent 3073a0d commit 7314754
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const runTests = async (out = false) => {
// await queueTagAsync("Imgur", bikeTagImgurInstance, out)
// await getQueueAsync("Imgur", bikeTagImgurInstance, out)
// await getCurrentTagAsync("Imgur", bikeTagImgurInstance, out)
await get10TagsAsync("Imgur", bikeTagImgurInstance, out)
// await get10TagsAsync("Imgur", bikeTagImgurInstance, out)
// await get10PlayersAsync("Imgur", bikeTagImgurInstance, out)
}

Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Support the BikeTag Project on [GitHub][github], [Patreon][patreon], or directly
[sanity]: https://www.sanity.io/docs/api-versioning
[imgur]: https://www.npmjs.com/package/imgur/v/next

![Alt](https://repobeats.axiom.co/api/embed/efea76b8d7f37062fcded362417a369dc9a3a401.svg "Repobeats analytics image")

<div align="center">

Expand Down
3 changes: 3 additions & 0 deletions src/common/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export const getTagNumbersFromText = (
if (!tagNumberText) return fallback || []

const tagNumbers = tagNumberText.reduce((numbers, text) => {
if (!text) return numbers

const tagNumberMatches = text.match(/\d+/)
const tagNumber =
tagNumberMatches && tagNumberMatches.length ? tagNumberMatches[0] : null
Expand Down Expand Up @@ -217,6 +219,7 @@ export const getGPSLocationFromText = (
): geopoint => {
const gpsString = getGpsStringLocationFromText(inputText, '', cache)

/// Encode/decode the GPS string here
if (gpsString.length) {
const gpsPair = gpsString.split(',')
const gpsLocation = {
Expand Down
2 changes: 1 addition & 1 deletion src/common/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export const getGameAlbumFromCache = async (
gameAlbumHash: string,
cache?: typeof TinyCache,
fallback?: any
) => {
): Promise<any> => {
const cacheKey = `imgur::${cacheKeys.albumHash}${gameAlbumHash}`
const existsInCache = getCacheIfExists(cacheKey, cache)
if (existsInCache) {
Expand Down
6 changes: 5 additions & 1 deletion src/imgur/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export function getTagNumbersFromText(
fallback: number[] | null = null,
cache?: typeof TinyCache
): number[] {
if (!inputText?.length) return fallback

const cacheKey = `${cacheKeys.tagNumberText}${inputText}`
const existingParsed = getCacheIfExists(cacheKey)
if (existingParsed) return existingParsed
Expand All @@ -64,8 +66,10 @@ export function getTagNumbersFromText(
if (!tagNumberText) return fallback ?? []

const tagNumbers = tagNumberText.reduce((numbers, text) => {
if (!text) return numbers

let tagNumber: any = text.match(/\d+/)
tagNumber = tagNumber && tagNumber.length ? tagNumber[0] : null
tagNumber = tagNumber?.length ? tagNumber[0] : null

if (!tagNumber) return numbers

Expand Down

0 comments on commit 7314754

Please sign in to comment.