Skip to content

Commit fe31a0d

Browse files
authored
Fix an issue with Referrers in Stats showing invalid icons (#23943)
2 parents 309ddbc + 2f22b2f commit fe31a0d

File tree

3 files changed

+94
-64
lines changed

3 files changed

+94
-64
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* [*] Fix incorrect chevron icons direction in RTL languages [#23940]
1313
* [*] Fix an issue with clear navigation bar background in revision browser [#23941]
1414
* [*] Fix an issue with comments being lost on request failure [#23942]
15+
* [*] Fix an issue with Referrers in Stats showing invalid icons [#23943]
1516

1617
25.6
1718
-----

WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodViewModel.swift

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -502,27 +502,19 @@ private extension SiteStatsPeriodViewModel {
502502
let referrers = store.getTopReferrers()?.referrers.prefix(10) ?? []
503503

504504
func rowDataFromReferrer(referrer: StatsReferrer) -> StatsTotalRowData {
505-
var icon: UIImage? = nil
506-
var iconURL: URL? = nil
507-
508-
switch referrer.iconURL?.lastPathComponent {
509-
case "search-engine.png":
510-
icon = Style.imageForGridiconType(.search)
511-
case nil:
512-
icon = Style.imageForGridiconType(.globe)
513-
default:
514-
iconURL = referrer.iconURL
515-
}
516-
517-
return StatsTotalRowData(name: referrer.title,
518-
data: referrer.viewsCount.abbreviatedString(),
519-
icon: icon,
520-
socialIconURL: iconURL,
521-
showDisclosure: true,
522-
disclosureURL: referrer.url,
523-
childRows: referrer.children.map { rowDataFromReferrer(referrer: $0) },
524-
statSection: .periodReferrers,
525-
isReferrerSpam: referrer.isSpam)
505+
return StatsTotalRowData(
506+
name: referrer.title,
507+
data: referrer.viewsCount.abbreviatedString(),
508+
icon: nil,
509+
socialIconURL: nil,
510+
showDisclosure: true,
511+
disclosureURL: referrer.url,
512+
childRows: referrer.children.map {
513+
rowDataFromReferrer(referrer: $0)
514+
},
515+
statSection: .periodReferrers,
516+
isReferrerSpam: referrer.isSpam
517+
)
526518
}
527519

528520
return referrers.map { rowDataFromReferrer(referrer: $0) }

WordPress/Classes/ViewRelated/Stats/Shared Views/Stats Detail/SiteStatsInsightsDetailsViewModel.swift

Lines changed: 80 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -274,26 +274,33 @@ class SiteStatsInsightsDetailsViewModel: Observable {
274274

275275
// Views Visitors
276276
let weekEnd = futureEndOfWeekDate(for: periodSummary)
277-
rows.append(contentsOf: SiteStatsImmuTableRows.viewVisitorsImmuTableRows(periodSummary,
278-
selectedSegment: selectedViewsVisitorsSegment,
279-
periodDate: selectedDate!,
280-
periodEndDate: weekEnd,
281-
siteStatsInsightsDelegate: nil,
282-
viewsAndVisitorsDelegate: viewsAndVisitorsDelegate))
277+
rows.append(
278+
contentsOf: SiteStatsImmuTableRows.viewVisitorsImmuTableRows(
279+
periodSummary,
280+
selectedSegment: selectedViewsVisitorsSegment,
281+
periodDate: selectedDate!,
282+
periodEndDate: weekEnd,
283+
siteStatsInsightsDelegate: nil,
284+
viewsAndVisitorsDelegate: viewsAndVisitorsDelegate
285+
)
286+
)
283287

284288
// Referrers
285289
if let referrers = viewsAndVisitorsData.topReferrers {
286290
let referrersData = referrersRowData(topReferrers: referrers)
287291
let chartViewModel = StatsReferrersChartViewModel(referrers: referrers)
288292
let chartView: UIView? = referrers.totalReferrerViewsCount > 0 ? chartViewModel.makeReferrersChartView() : nil
289293

290-
var referrersRow = TopTotalsPeriodStatsRow(itemSubtitle: StatSection.periodReferrers.itemSubtitle,
291-
dataSubtitle: StatSection.periodReferrers.dataSubtitle,
292-
dataRows: referrersData,
293-
statSection: StatSection.periodReferrers,
294-
siteStatsPeriodDelegate: nil, //TODO - look at if I need to be not null
295-
siteStatsReferrerDelegate: nil,
296-
siteStatsInsightsDetailsDelegate: insightsDetailsDelegate)
294+
var referrersRow = TopTotalsPeriodStatsRow(
295+
itemSubtitle: StatSection.periodReferrers.itemSubtitle,
296+
dataSubtitle: StatSection.periodReferrers.dataSubtitle,
297+
dataRows: referrersData,
298+
statSection: StatSection.periodReferrers,
299+
siteStatsPeriodDelegate: nil,
300+
//TODO - look at if I need to be not null
301+
siteStatsReferrerDelegate: nil,
302+
siteStatsInsightsDetailsDelegate: insightsDetailsDelegate
303+
)
297304
referrersRow.topAccessoryView = chartView
298305
rows.append(referrersRow)
299306
}
@@ -304,12 +311,18 @@ class SiteStatsInsightsDetailsViewModel: Observable {
304311
if isMapShown {
305312
rows.append(CountriesMapRow(countriesMap: map, statSection: .periodCountries))
306313
}
307-
rows.append(CountriesStatsRow(itemSubtitle: StatSection.periodCountries.itemSubtitle,
308-
dataSubtitle: StatSection.periodCountries.dataSubtitle,
309-
statSection: isMapShown ? nil : .periodCountries,
310-
dataRows: countriesRowData(topCountries: viewsAndVisitorsData.topCountries),
311-
siteStatsPeriodDelegate: nil,
312-
siteStatsInsightsDetailsDelegate: insightsDetailsDelegate))
314+
rows.append(
315+
CountriesStatsRow(
316+
itemSubtitle: StatSection.periodCountries.itemSubtitle,
317+
dataSubtitle: StatSection.periodCountries.dataSubtitle,
318+
statSection: isMapShown ? nil : .periodCountries,
319+
dataRows: countriesRowData(
320+
topCountries: viewsAndVisitorsData.topCountries
321+
),
322+
siteStatsPeriodDelegate: nil,
323+
siteStatsInsightsDetailsDelegate: insightsDetailsDelegate
324+
)
325+
)
313326
return rows
314327
}
315328

@@ -326,29 +339,42 @@ class SiteStatsInsightsDetailsViewModel: Observable {
326339
let emailFollowersCount = insightsStore.getEmailFollowers()?.emailFollowersCount ?? 0
327340

328341
if dotComFollowersCount > 0 || emailFollowersCount > 0 {
329-
let chartViewModel = StatsFollowersChartViewModel(dotComFollowersCount: dotComFollowersCount,
330-
emailFollowersCount: emailFollowersCount)
342+
let chartViewModel = StatsFollowersChartViewModel(
343+
dotComFollowersCount: dotComFollowersCount,
344+
emailFollowersCount: emailFollowersCount
345+
)
331346

332347
let chartView: UIView = chartViewModel.makeFollowersChartView()
333348

334-
var chartRow = TopTotalsPeriodStatsRow(itemSubtitle: "",
335-
dataSubtitle: "",
336-
dataRows: followersRowData(dotComFollowersCount: dotComFollowersCount,
337-
emailFollowersCount: emailFollowersCount,
338-
totalCount: dotComFollowersCount + emailFollowersCount),
339-
statSection: StatSection.insightsFollowersWordPress,
340-
siteStatsPeriodDelegate: nil, //TODO - look at if I need to be not null
341-
siteStatsReferrerDelegate: nil)
349+
var chartRow = TopTotalsPeriodStatsRow(
350+
itemSubtitle: "",
351+
dataSubtitle: "",
352+
dataRows: followersRowData(
353+
dotComFollowersCount: dotComFollowersCount,
354+
emailFollowersCount: emailFollowersCount,
355+
totalCount: dotComFollowersCount + emailFollowersCount
356+
),
357+
statSection: StatSection.insightsFollowersWordPress,
358+
siteStatsPeriodDelegate: nil,
359+
//TODO - look at if I need to be not null
360+
siteStatsReferrerDelegate: nil
361+
)
342362
chartRow.topAccessoryView = chartView
343363
rows.append(chartRow)
344364
}
345365

346-
rows.append(TabbedTotalsStatsRow(tabsData: [tabDataForFollowerType(.insightsFollowersWordPress),
347-
tabDataForFollowerType(.insightsFollowersEmail)],
366+
rows.append(
367+
TabbedTotalsStatsRow(
368+
tabsData: [
369+
tabDataForFollowerType(.insightsFollowersWordPress),
370+
tabDataForFollowerType(.insightsFollowersEmail)
371+
],
348372
statSection: .insightsFollowersWordPress,
349373
siteStatsInsightsDelegate: insightsDetailsDelegate,
350374
siteStatsDetailsDelegate: detailsDelegate,
351-
showTotalCount: false))
375+
showTotalCount: false
376+
)
377+
)
352378
return rows
353379
}
354380
case .insightsLikesTotals:
@@ -358,21 +384,32 @@ class SiteStatsInsightsDetailsViewModel: Observable {
358384
let likesTotalsData = revampStore.getLikesTotalsData()
359385

360386
if let summary = likesTotalsData.summary {
361-
rows.append(TotalInsightStatsRow(dataRow: createLikesTotalInsightsRow(periodSummary: summary),
362-
statSection: statSection,
363-
siteStatsInsightsDelegate: nil)
387+
rows.append(
388+
TotalInsightStatsRow(
389+
dataRow: createLikesTotalInsightsRow(
390+
periodSummary: summary
391+
),
392+
statSection: statSection,
393+
siteStatsInsightsDelegate: nil
394+
)
364395
)
365396
}
366397

367398
if let topPostsAndPages = likesTotalsData.topPostsAndPages {
368-
rows.append(TopTotalsPeriodStatsRow(itemSubtitle: StatSection.periodPostsAndPages.itemSubtitle,
369-
dataSubtitle: StatSection.periodPostsAndPages.dataSubtitle,
370-
dataRows: postsAndPagesRowData(topPostsAndPages: topPostsAndPages),
371-
statSection: StatSection.periodPostsAndPages,
372-
siteStatsPeriodDelegate: nil,
373-
siteStatsReferrerDelegate: nil,
374-
siteStatsInsightsDetailsDelegate: insightsDetailsDelegate,
375-
siteStatsDetailsDelegate: detailsDelegate))
399+
rows.append(
400+
TopTotalsPeriodStatsRow(
401+
itemSubtitle: StatSection.periodPostsAndPages.itemSubtitle,
402+
dataSubtitle: StatSection.periodPostsAndPages.dataSubtitle,
403+
dataRows: postsAndPagesRowData(
404+
topPostsAndPages: topPostsAndPages
405+
),
406+
statSection: StatSection.periodPostsAndPages,
407+
siteStatsPeriodDelegate: nil,
408+
siteStatsReferrerDelegate: nil,
409+
siteStatsInsightsDetailsDelegate: insightsDetailsDelegate,
410+
siteStatsDetailsDelegate: detailsDelegate
411+
)
412+
)
376413
}
377414

378415
return rows

0 commit comments

Comments
 (0)