diff --git a/submodules/GraphUI/Sources/ChartNode.swift b/submodules/GraphUI/Sources/ChartNode.swift index c461832c06..2bb978f416 100644 --- a/submodules/GraphUI/Sources/ChartNode.swift +++ b/submodules/GraphUI/Sources/ChartNode.swift @@ -147,12 +147,16 @@ public final class ChartNode: ASDisplayNode { self.chartView.apply(theme: theme, strings: strings, animated: false) } - public func setup(controller: BaseChartController) { + public func setup(controller: BaseChartController, noInitialZoom: Bool = false) { var displayRange = true + var zoomToEnding = true if let controller = controller as? StepBarsChartController { displayRange = !controller.hourly } - self.chartView.setup(controller: controller, displayRange: displayRange) + if noInitialZoom { + zoomToEnding = false + } + self.chartView.setup(controller: controller, displayRange: displayRange, zoomToEnding: zoomToEnding) } public func resetInteraction() { diff --git a/submodules/GraphUI/Sources/ChartStackSection.swift b/submodules/GraphUI/Sources/ChartStackSection.swift index 7e35df4bcc..d0c5f41cc3 100644 --- a/submodules/GraphUI/Sources/ChartStackSection.swift +++ b/submodules/GraphUI/Sources/ChartStackSection.swift @@ -181,7 +181,7 @@ class ChartStackSection: UIView, ChartThemeContainer { self.chartView.setNeedsDisplay() } - func setup(controller: BaseChartController, displayRange: Bool = true) { + func setup(controller: BaseChartController, displayRange: Bool = true, zoomToEnding: Bool = true) { self.controller = controller self.displayRange = displayRange @@ -246,7 +246,7 @@ class ChartStackSection: UIView, ChartThemeContainer { controller.initializeChart() updateToolViews(animated: false) - let range: ClosedRange = displayRange ? 0.8 ... 1.0 : 0.0 ... 1.0 + let range: ClosedRange = displayRange && zoomToEnding ? 0.8 ... 1.0 : 0.0 ... 1.0 rangeView.setRange(range, animated: false) controller.updateChartRange(range, animated: false) diff --git a/submodules/StatisticsUI/Sources/MessageStatsController.swift b/submodules/StatisticsUI/Sources/MessageStatsController.swift index 3d57776f4c..8fd3b198b6 100644 --- a/submodules/StatisticsUI/Sources/MessageStatsController.swift +++ b/submodules/StatisticsUI/Sources/MessageStatsController.swift @@ -39,10 +39,10 @@ private enum StatsEntry: ItemListNodeEntry { case overview(PresentationTheme, PostStats, Int32?) case interactionsTitle(PresentationTheme, String) - case interactionsGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType) + case interactionsGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType, Bool) case reactionsTitle(PresentationTheme, String) - case reactionsGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType) + case reactionsGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType, Bool) case publicForwardsTitle(PresentationTheme, String) case publicForward(Int32, PresentationTheme, PresentationStrings, PresentationDateTimeFormat, EngineMessage) @@ -53,7 +53,7 @@ private enum StatsEntry: ItemListNodeEntry { return StatsSection.overview.rawValue case .interactionsTitle, .interactionsGraph: return StatsSection.interactions.rawValue - case .reactionsTitle, .reactionsGraph: + case .reactionsTitle, .reactionsGraph: return StatsSection.reactions.rawValue case .publicForwardsTitle, .publicForward: return StatsSection.publicForwards.rawValue @@ -107,8 +107,8 @@ private enum StatsEntry: ItemListNodeEntry { } else { return false } - case let .interactionsGraph(lhsTheme, lhsStrings, lhsDateTimeFormat, lhsGraph, lhsType): - if case let .interactionsGraph(rhsTheme, rhsStrings, rhsDateTimeFormat, rhsGraph, rhsType) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsGraph == rhsGraph, lhsType == rhsType { + case let .interactionsGraph(lhsTheme, lhsStrings, lhsDateTimeFormat, lhsGraph, lhsType, lhsNoInitialZoom): + if case let .interactionsGraph(rhsTheme, rhsStrings, rhsDateTimeFormat, rhsGraph, rhsType, rhsNoInitialZoom) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsGraph == rhsGraph, lhsType == rhsType, lhsNoInitialZoom == rhsNoInitialZoom { return true } else { return false @@ -119,8 +119,8 @@ private enum StatsEntry: ItemListNodeEntry { } else { return false } - case let .reactionsGraph(lhsTheme, lhsStrings, lhsDateTimeFormat, lhsGraph, lhsType): - if case let .reactionsGraph(rhsTheme, rhsStrings, rhsDateTimeFormat, rhsGraph, rhsType) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsGraph == rhsGraph, lhsType == rhsType { + case let .reactionsGraph(lhsTheme, lhsStrings, lhsDateTimeFormat, lhsGraph, lhsType, lhsNoInitialZoom): + if case let .reactionsGraph(rhsTheme, rhsStrings, rhsDateTimeFormat, rhsGraph, rhsType, rhsNoInitialZoom) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsGraph == rhsGraph, lhsType == rhsType, lhsNoInitialZoom == rhsNoInitialZoom { return true } else { return false @@ -154,8 +154,8 @@ private enum StatsEntry: ItemListNodeEntry { return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) case let .overview(_, stats, publicShares): return StatsOverviewItem(presentationData: presentationData, stats: stats as! Stats, publicShares: publicShares, sectionId: self.section, style: .blocks) - case let .interactionsGraph(_, _, _, graph, type), let .reactionsGraph(_, _, _, graph, type): - return StatsGraphItem(presentationData: presentationData, graph: graph, type: type, getDetailsData: { date, completion in + case let .interactionsGraph(_, _, _, graph, type, noInitialZoom), let .reactionsGraph(_, _, _, graph, type, noInitialZoom): + return StatsGraphItem(presentationData: presentationData, graph: graph, type: type, noInitialZoom: noInitialZoom, getDetailsData: { date, completion in let _ = arguments.loadDetailedGraph(graph, Int64(date.timeIntervalSince1970) * 1000).start(next: { graph in if let graph = graph, case let .Loaded(_, data) = graph { completion(data) @@ -185,6 +185,11 @@ private func messageStatsControllerEntries(data: PostStats?, messages: SearchMes if let data = data { entries.append(.overviewTitle(presentationData.theme, presentationData.strings.Stats_MessageOverview.uppercased())) entries.append(.overview(presentationData.theme, data, messages?.totalCount)) + + var isStories = false + if let _ = data as? StoryStats { + isStories = true + } if !data.interactionsGraph.isEmpty { entries.append(.interactionsTitle(presentationData.theme, presentationData.strings.Stats_MessageInteractionsTitle.uppercased())) @@ -198,12 +203,12 @@ private func messageStatsControllerEntries(data: PostStats?, messages: SearchMes chartType = .twoAxisStep } - entries.append(.interactionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.interactionsGraph, chartType)) + entries.append(.interactionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.interactionsGraph, chartType, isStories)) } if !data.reactionsGraph.isEmpty { entries.append(.reactionsTitle(presentationData.theme, presentationData.strings.Stats_MessageReactionsTitle.uppercased())) - entries.append(.reactionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.reactionsGraph, .bars)) + entries.append(.reactionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.reactionsGraph, .bars, isStories)) } if let messages = messages, !messages.messages.isEmpty { diff --git a/submodules/StatisticsUI/Sources/StatsGraphItem.swift b/submodules/StatisticsUI/Sources/StatsGraphItem.swift index 486051b656..c0abb3021d 100644 --- a/submodules/StatisticsUI/Sources/StatsGraphItem.swift +++ b/submodules/StatisticsUI/Sources/StatsGraphItem.swift @@ -15,14 +15,16 @@ class StatsGraphItem: ListViewItem, ItemListItem { let presentationData: ItemListPresentationData let graph: StatsGraph let type: ChartType + let noInitialZoom: Bool let getDetailsData: ((Date, @escaping (String?) -> Void) -> Void)? let sectionId: ItemListSectionId let style: ItemListStyle - init(presentationData: ItemListPresentationData, graph: StatsGraph, type: ChartType, getDetailsData: ((Date, @escaping (String?) -> Void) -> Void)? = nil, sectionId: ItemListSectionId, style: ItemListStyle) { + init(presentationData: ItemListPresentationData, graph: StatsGraph, type: ChartType, noInitialZoom: Bool = false, getDetailsData: ((Date, @escaping (String?) -> Void) -> Void)? = nil, sectionId: ItemListSectionId, style: ItemListStyle) { self.presentationData = presentationData self.graph = graph self.type = type + self.noInitialZoom = noInitialZoom self.getDetailsData = getDetailsData self.sectionId = sectionId self.style = style @@ -266,7 +268,7 @@ class StatsGraphItemNode: ListViewItemNode { if let updatedGraph = updatedGraph { if case .Loaded = updatedGraph, let updatedController = updatedController { - strongSelf.chartNode.setup(controller: updatedController) + strongSelf.chartNode.setup(controller: updatedController, noInitialZoom: item.noInitialZoom) strongSelf.activityIndicator.isHidden = true strongSelf.chartNode.isHidden = false } else if case .OnDemand = updatedGraph { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift index 94bbddc725..835fea4f8d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift @@ -612,7 +612,7 @@ private final class ChannelItemComponent: Component { maximumNumberOfLines: 2 )), environment: {}, - containerSize: CGSize(width: itemSize.width - 16.0, height: 100.0) + containerSize: CGSize(width: itemSize.width - 9.0, height: 100.0) ) let subtitleSize = self.subtitle.update(