Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,9 @@ target 'JetpackDraftActionExtension' do
wordpress_ui
end

## Home Screen Widgets
## Widgets
## ============
##
target 'WordPressStatsWidgets' do
project 'WordPress/WordPress.xcodeproj'

shared_with_all_pods
shared_with_networking_pods
shared_style_pods

wordpress_ui
end

target 'JetpackStatsWidgets' do
project 'WordPress/WordPress.xcodeproj'
Expand All @@ -253,14 +244,6 @@ end
## Intents
## ============
##
target 'WordPressIntents' do
project 'WordPress/WordPress.xcodeproj'

shared_with_all_pods
shared_with_networking_pods

wordpress_ui
end

target 'JetpackIntents' do
project 'WordPress/WordPress.xcodeproj'
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: d170fa8e270b2a32bef9dcdcabff5b8f1a5deced

PODFILE CHECKSUM: ecda009f9b2ab8373b422cc4a4f4957dab257ddf
PODFILE CHECKSUM: b99ef82bab1e59cf8ae03a030caae5e2a50d5522

COCOAPODS: 1.12.1
32 changes: 0 additions & 32 deletions WordPress/Classes/Services/AccountService.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#import "CoreDataStack.h"
#import "Blog.h"
#import "BlogService.h"
#import "TodayExtensionService.h"

@import WordPressKit;
@import WordPressShared;
Expand Down Expand Up @@ -403,49 +402,18 @@ - (void)setupAppExtensionsWithDefaultAccount:(WPAccount *)defaultAccount inConte
Blog *defaultBlog = [defaultAccount defaultBlog];
NSNumber *siteId = defaultBlog.dotComID;
NSString *blogName = defaultBlog.settings.name;
NSString *blogUrl = defaultBlog.displayURL;

if (defaultBlog == nil || defaultBlog.isDeleted) {
dispatch_async(dispatch_get_main_queue(), ^{
TodayExtensionService *service = [TodayExtensionService new];
[service removeTodayWidgetConfiguration];

[ShareExtensionService removeShareExtensionConfiguration];

[NotificationSupportService deleteContentExtensionToken];
[NotificationSupportService deleteServiceExtensionToken];
});
} else {
// Required Attributes

NSString *oauth2Token = defaultAccount.authToken;

// For the Today Extensions, if the user has set a non-primary site, use that.
NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:WPAppGroupName];
NSNumber *todayExtensionSiteID = [sharedDefaults objectForKey:AppConfigurationWidgetStatsToday.userDefaultsSiteIdKey];
NSString *todayExtensionBlogName = [sharedDefaults objectForKey:AppConfigurationWidgetStatsToday.userDefaultsSiteNameKey];
NSString *todayExtensionBlogUrl = [sharedDefaults objectForKey:AppConfigurationWidgetStatsToday.userDefaultsSiteUrlKey];

Blog *todayExtensionBlog = [Blog lookupWithID:todayExtensionSiteID in:context];
NSTimeZone *timeZone = [todayExtensionBlog timeZone];

if (todayExtensionSiteID == NULL || todayExtensionBlog == nil) {
todayExtensionSiteID = siteId;
todayExtensionBlogName = blogName;
todayExtensionBlogUrl = blogUrl;
timeZone = [defaultBlog timeZone];
}

dispatch_async(dispatch_get_main_queue(), ^{
WPAccount *defaultAccount = [self.coreDataStack.mainContext existingObjectWithID:defaultAccountObjectID error:nil];

TodayExtensionService *service = [TodayExtensionService new];
[service configureTodayWidgetWithSiteID:todayExtensionSiteID
blogName:todayExtensionBlogName
blogUrl:todayExtensionBlogUrl
siteTimeZone:timeZone
andOAuth2Token:oauth2Token];

[ShareExtensionService configureShareExtensionDefaultSiteID:siteId.integerValue defaultSiteName:blogName];
[ShareExtensionService configureShareExtensionToken:defaultAccount.authToken];
[ShareExtensionService configureShareExtensionUsername:defaultAccount.username];
Expand Down
1 change: 0 additions & 1 deletion WordPress/Classes/Services/BlogService.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#import "PostCategoryService.h"
#import "CommentService.h"
#import "PostService.h"
#import "TodayExtensionService.h"
#import "WordPress-Swift.h"
#import "PostType.h"
@import WordPressKit;
Expand Down
15 changes: 0 additions & 15 deletions WordPress/Classes/Services/TodayExtensionService.h

This file was deleted.

78 changes: 0 additions & 78 deletions WordPress/Classes/Services/TodayExtensionService.m

This file was deleted.

33 changes: 0 additions & 33 deletions WordPress/Classes/Stores/StatsInsightsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ struct InsightStoreState {
visitors: stats.visitorsCount,
posts: stats.postsCount,
bestViews: stats.bestViewsPerDayCount)
storeAllTimeWidgetData(data: widgetData)
StoreContainer.shared.statsWidgets.storeHomeWidgetData(widgetType: HomeWidgetAllTimeData.self, stats: widgetData)
}
}
Expand Down Expand Up @@ -93,7 +92,6 @@ struct InsightStoreState {
likes: stats.likesCount,
comments: stats.commentsCount)

storeTodayWidgetData(data: widgetData)
StoreContainer.shared.statsWidgets.storeHomeWidgetData(widgetType: HomeWidgetTodayData.self, stats: widgetData)
}
}
Expand Down Expand Up @@ -1038,37 +1036,6 @@ extension StatsInsightsStore {
}
}

// MARK: - Widget Data

private extension InsightStoreState {

func storeTodayWidgetData(data: TodayWidgetStats) {
guard widgetUsingCurrentSite() else {
return
}

data.saveData()
}

func storeAllTimeWidgetData(data: AllTimeWidgetStats) {
guard widgetUsingCurrentSite() else {
return
}

data.saveData()
}

func widgetUsingCurrentSite() -> Bool {
// Only store data if the widget is using the current site.
guard let sharedDefaults = UserDefaults(suiteName: WPAppGroupName),
let widgetSiteID = sharedDefaults.object(forKey: AppConfiguration.Widget.StatsToday.userDefaultsSiteIdKey) as? NSNumber,
widgetSiteID == SiteStatsInformation.sharedInstance.siteID else {
return false
}
return true
}
}

// MARK: - Posting Activity Private Methods

private extension StatsInsightsStore {
Expand Down
30 changes: 0 additions & 30 deletions WordPress/Classes/Stores/StatsPeriodStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ struct PeriodStoreState {

var summary: StatsSummaryTimeIntervalData? {
didSet {
storeThisWeekWidgetData()
StoreContainer.shared.statsWidgets.updateThisWeekHomeWidget(summary: summary)
storeTodayHomeWidgetData()
}
Expand Down Expand Up @@ -1389,35 +1388,6 @@ private extension PeriodStoreState {
comments: todayData.commentsCount)
StoreContainer.shared.statsWidgets.storeHomeWidgetData(widgetType: HomeWidgetTodayData.self, stats: todayWidgetStats)
}

func storeThisWeekWidgetData() {
// Only store data if:
// - The widget is using the current site
// - The summary period is days
// - The summary period end date is the current date

guard widgetUsingCurrentSite(),
let summary,
summary.period == .day,
summary.periodEndDate == StatsDataHelper.currentDateForSite().normalizedDate() else {
return
}

// Include an extra day. It's needed to get the dailyChange for the last day.
let summaryData = Array(summary.summaryData.reversed().prefix(ThisWeekWidgetStats.maxDaysToDisplay + 1))

let widgetData = ThisWeekWidgetStats(days: ThisWeekWidgetStats.daysFrom(summaryData: summaryData))
widgetData.saveData()
}

func widgetUsingCurrentSite() -> Bool {
guard let sharedDefaults = UserDefaults(suiteName: WPAppGroupName),
let widgetSiteID = sharedDefaults.object(forKey: AppConfiguration.Widget.StatsToday.userDefaultsSiteIdKey) as? NSNumber,
widgetSiteID == SiteStatsInformation.sharedInstance.siteID else {
return false
}
return true
}
}

// MARK: - Toggle referrer spam state helper
Expand Down
22 changes: 0 additions & 22 deletions WordPress/Classes/Stores/StatsWidgetsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ class StatsWidgetsStore {
init(coreDataStack: CoreDataStack = ContextManager.shared) {
self.coreDataStack = coreDataStack

updateJetpackFeaturesDisabled()
observeAccountChangesForWidgets()
observeAccountSignInForWidgets()
observeApplicationLaunched()
observeSiteUpdatesForWidgets()
observeJetpackFeaturesState()
}

/// Refreshes the site list used to configure the widgets when sites are added or deleted
Expand Down Expand Up @@ -295,26 +293,6 @@ private extension StatsWidgetsStore {
@objc private func handleApplicationLaunchCompleted() {
handleJetpackWidgetsMigration()
}

func observeJetpackFeaturesState() {
NotificationCenter.default.addObserver(self,
selector: #selector(updateJetpackFeaturesDisabled),
name: .WPAppUITypeChanged,
object: nil)
}

@objc func updateJetpackFeaturesDisabled() {
guard let defaults = UserDefaults(suiteName: WPAppGroupName) else {
return
}
let key = AppConfiguration.Widget.Stats.userDefaultsJetpackFeaturesDisabledKey
let oldValue = defaults.bool(forKey: key)
let newValue = !JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled()
defaults.setValue(newValue, forKey: key)
if oldValue != newValue {
refreshStatsWidgetsSiteList()
}
}
}

private extension StatsWidgetsStore {
Expand Down
1 change: 0 additions & 1 deletion WordPress/Classes/System/WordPress-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@

#import "Theme.h"
#import "ThemeService.h"
#import "TodayExtensionService.h"

#import "UIAlertControllerProxy.h"
#import "UIApplication+Helpers.h"
Expand Down
7 changes: 0 additions & 7 deletions WordPress/Classes/System/WordPressAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,6 @@ extension WordPressAppDelegate {
AccountService.loadDefaultAccountCookies()
} else {
trackLogoutIfNeeded()
removeTodayWidgetConfiguration()
removeShareExtensionConfiguration()
removeNotificationExtensionConfiguration()
windowManager.showFullscreenSignIn()
Expand Down Expand Up @@ -843,12 +842,6 @@ extension WordPressAppDelegate {
saveRecentSitesForExtensions()
}

// MARK: - Today Extension

func removeTodayWidgetConfiguration() {
TodayExtensionService().removeTodayWidgetConfiguration()
}

// MARK: - Share Extension

func setupShareExtensionToken() {
Expand Down
3 changes: 0 additions & 3 deletions WordPress/Classes/Utility/AccountHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ import Foundation
// Also clear the spotlight index
SearchManager.shared.deleteAllSearchableItems()

// Clear Today Widgets' stored data
StatsDataHelper.clearWidgetsData()

// Delete donated user activities (e.g., for Siri Shortcuts)
NSUserActivity.deleteAllSavedUserActivities {}

Expand Down
Loading