Skip to content

Commit

Permalink
Removed pingbackeventtype from normalize.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksantan authored and giannif committed Apr 22, 2024
1 parent 7c22174 commit 42a1e2a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/fetch-api/src/normalize/gif.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IGif, PingbackEventType } from '@giphy/js-types'
import { IGif } from '@giphy/js-types'
import { GifResult, GifsResult } from '../result-types'

/**
Expand Down Expand Up @@ -29,7 +29,7 @@ type Tag = { text: string }
// tags sometimes are objects that have a text prop, sometimes they're strings
const getTag = (tag: Tag | string) => (typeof tag === 'string' ? (tag as string) : (tag as Tag).text)

const normalize = (gif: any, responseId: string = '', pingbackType: PingbackEventType = '') => {
const normalize = (gif: any, responseId: string = '') => {
const newGif: IGif = { ...gif }
newGif.id = String(newGif.id)
newGif.tags = (newGif.tags || []).map(getTag)
Expand All @@ -38,11 +38,8 @@ const normalize = (gif: any, responseId: string = '', pingbackType: PingbackEven
}
if (responseId) {
newGif.response_id = responseId
// @ts-ignore
newGif.pingbackType = pingbackType
}
newGif.response_id = responseId
newGif.pingback_event_type = pingbackType
BOOL_PROPS.forEach(makeBool(newGif))
Object.keys(newGif.images || {}).forEach((name: string) => {
const img = newGif.images[name]
Expand All @@ -62,17 +59,17 @@ const normalize = (gif: any, responseId: string = '', pingbackType: PingbackEven
/**
* @hidden
*/
export const normalizeGif = (result: GifResult, pingbackType?: PingbackEventType) => {
export const normalizeGif = (result: GifResult) => {
const { response_id } = result.meta
result.data = normalize(result.data, response_id, pingbackType)
result.data = normalize(result.data, response_id)
return result
}

/**
* @hidden
*/
export const normalizeGifs = (result: GifsResult, pingbackType?: PingbackEventType) => {
export const normalizeGifs = (result: GifsResult) => {
const { response_id } = result.meta
result.data = result.data.map((gif) => normalize(gif, response_id, pingbackType))
result.data = result.data.map((gif) => normalize(gif, response_id))
return result
}

0 comments on commit 42a1e2a

Please sign in to comment.