@playpilot/tpi 6.2.7 → 6.2.9

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": "@playpilot/tpi",
3
- "version": "6.2.7",
3
+ "version": "6.2.9",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { heading } from '$lib/actions/heading'
3
+ import { fetchAds } from '$lib/api/ads'
3
4
  import { fetchTitles } from '$lib/api/titles'
4
5
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
5
6
  import { exploreParentSelector } from '$lib/explore'
@@ -46,7 +47,11 @@
46
47
  height = element?.closest<HTMLElement>(exploreParentSelector)?.style.height || null
47
48
  })
48
49
 
49
- onMount(() => track(TrackingEvent.ExplorePageView))
50
+ onMount(async () => {
51
+ track(TrackingEvent.ExplorePageView)
52
+
53
+ if (!window.PlayPilotLinkInjections.ads?.length) window.PlayPilotLinkInjections.ads = await fetchAds()
54
+ })
50
55
 
51
56
  async function getTitlesForFilter(): Promise<APIPaginatedResult<TitleData>> {
52
57
  latestRequestId += 1
@@ -42,10 +42,12 @@
42
42
  if (!target) return
43
43
  if (!isDragging) return
44
44
 
45
+ event.preventDefault()
46
+
45
47
  movementCurrentY = event.touches[0].pageY
46
48
 
47
- target.style.transform = `translateY(${difference}px)`
48
- handleElement!.style.transform = `translateY(${difference}px)`
49
+ target.style.top = `${difference}px`
50
+ handleElement!.style.top = `${difference}px`
49
51
  }
50
52
 
51
53
  export function end(): void {
@@ -6,6 +6,7 @@ import { fetchTitles } from '$lib/api/titles'
6
6
  import { title } from '$lib/fakeData'
7
7
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
8
8
  import { track } from '$lib/tracking'
9
+ import { fetchAds } from '$lib/api/ads'
9
10
 
10
11
  vi.mock('$lib/api/titles', () => ({
11
12
  fetchTitles: vi.fn(),
@@ -19,8 +20,15 @@ vi.mock('$lib/tracking', () => ({
19
20
  track: vi.fn(),
20
21
  }))
21
22
 
23
+ vi.mock('$lib/api/ads', () => ({
24
+ fetchAds: vi.fn(),
25
+ }))
26
+
22
27
  describe('Explore.svelte', () => {
23
28
  beforeEach(() => {
29
+ // @ts-ignore
30
+ window.PlayPilotLinkInjections = {}
31
+
24
32
  vi.resetAllMocks()
25
33
  })
26
34
 
@@ -30,10 +38,23 @@ describe('Explore.svelte', () => {
30
38
  expect(fetchTitles).toHaveBeenCalledWith({ page_size: 24, page: 1 })
31
39
  })
32
40
 
33
- it('Should call tracking event on mount', () => {
41
+ it('Should call tracking event and fetchAds on mount', () => {
34
42
  render(Explore)
35
43
 
36
44
  expect(track).toHaveBeenCalledWith(TrackingEvent.ExplorePageView)
45
+ expect(fetchAds).toHaveBeenCalled()
46
+ })
47
+
48
+ it('Should not call fetchAds on mount if ads are already present', () => {
49
+ // @ts-ignore
50
+ window.PlayPilotLinkInjections = {
51
+ // @ts-ignore
52
+ ads: ['a'],
53
+ }
54
+
55
+ render(Explore)
56
+
57
+ expect(fetchAds).not.toHaveBeenCalled()
37
58
  })
38
59
 
39
60
  it('Should render all returned titles', async () => {