Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.2.7 #224

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "biketag",
"version": "3.2.6",
"version": "3.2.7",
"description": "The Javascript client API for BikeTag Games",
"main": "./biketag.node.js",
"browser": "./biketag.js",
Expand Down
21 changes: 17 additions & 4 deletions src/common/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,21 @@ export const getImgurFoundDescriptionFromBikeTagData = (
includeDate ? getDateStringForImgurDescription(tag.foundTime) : ''
}`

export const getImgurFoundTitleFromBikeTagData = (tag: Tag): string =>
export const getImgurFoundTitleFromBikeTagData = (
tag: Tag,
fromCombinedTag = false
): string =>
`${
!tag.gps || (tag.gps.lat === 0 && tag.gps.long === 0)
? ''
: `(${tag.gps.lat ?? 0}, ${tag.gps.long ?? 0}, ${tag.gps.alt ?? 0})`
}
${tag.playerId?.length ? `[${tag.playerId}]` : ''}
${
!fromCombinedTag && // don't include the player id from a combined tag in the found tag
tag.playerId?.length
? `[${tag.playerId}]`
: ''
}
${tag.confirmedBoundary ? getConfirmedBoundarySymbol : ''}`

export const getImgurMysteryImageHashFromBikeTagData = (
Expand All @@ -500,9 +508,14 @@ export const getImgurMysteryImageHashFromBikeTagData = (
): string => {
return getImageHashFromText(tag.mysteryImageUrl, cache)
}
export const getImgurMysteryTitleFromBikeTagData = (tag: Tag): string =>
export const getImgurMysteryTitleFromBikeTagData = (
tag: Tag,
fromCombinedTag = false
): string =>
`${
!tag.gps || (tag.gps.lat === 0 && tag.gps.long === 0)
(!fromCombinedTag && // don't include the gps from a combined tag in the mystery
!tag.gps) ||
(tag.gps.lat === 0 && tag.gps.long === 0)
? ''
: `(${tag.gps.lat ?? 0}, ${tag.gps.long ?? 0}, ${tag.gps.alt ?? 0})`
}
Expand Down
7 changes: 4 additions & 3 deletions src/imgur/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,16 @@ export const isValidUploadTagImagePayload = (

export const getUpdateTagPayloadFromTagData = (
payload: uploadTagImagePayload,
mystery = false
mystery = false,
combined = false
): uploadTagImagePayload => {
return {
imageHash: mystery
? getImgurMysteryImageHashFromBikeTagData(payload as Tag)
: getImgurFoundImageHashFromBikeTagData(payload as Tag),
title: mystery
? getImgurMysteryTitleFromBikeTagData(payload as Tag)
: getImgurFoundTitleFromBikeTagData(payload as Tag),
? getImgurMysteryTitleFromBikeTagData(payload as Tag, combined)
: getImgurFoundTitleFromBikeTagData(payload as Tag, combined),
description: mystery
? getImgurMysteryDescriptionFromBikeTagData(payload as Tag)
: getImgurFoundDescriptionFromBikeTagData(payload as Tag),
Expand Down
12 changes: 10 additions & 2 deletions src/imgur/updateTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ export async function updateTag(
cache?: typeof TinyCache
): Promise<BikeTagApiResponse<Tag>> {
/// Construct imgur payloads for both mystery and found images separately
const imgurMysteryImagePayload = getUpdateTagPayloadFromTagData(payload, true)
const imgurFoundImagePayload = getUpdateTagPayloadFromTagData(payload)
const imgurMysteryImagePayload = getUpdateTagPayloadFromTagData(
payload,
true,
true
)
const imgurFoundImagePayload = getUpdateTagPayloadFromTagData(
payload,
false,
true
)

return new Promise(async (resolve) => {
let success = true
Expand Down