-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor FXIOS-10718 #23420 [sponsored tiles] Integrate unified ads A…
…PI (#23460) * Integrate Unified Tiles into Sponsored tiles in Top sites * Swiftlint * Fix stuff * Apply suggestions from code review Co-authored-by: Issam Mani <[email protected]> --------- Co-authored-by: Issam Mani <[email protected]>
- Loading branch information
Showing
3 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...fox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsConverter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
/// To keep the integration of unified ads simple with minimal changes, we are converting Unified tiles | ||
/// into the old API Contile object. This will avoid logic changes inside the TopSitesDataAdaptor, which will be deprecated | ||
/// soon anyway due to the refactor of the homepage. | ||
struct UnifiedAdsConverter { | ||
static func convert(unifiedTiles: [UnifiedTile]) -> [Contile] { | ||
return unifiedTiles.enumerated().map { (index, tile) in | ||
Contile( | ||
id: 0, // Was relevant for old telemetry, but not with unified ads | ||
name: tile.name, | ||
url: tile.url, | ||
clickUrl: tile.callbacks.click, | ||
imageUrl: tile.imageUrl, | ||
imageSize: 0, // Zero since not used anyway | ||
impressionUrl: tile.callbacks.impression, | ||
position: index + 1 // Keeping the same tile position as provided in the array | ||
) | ||
} | ||
} | ||
} |