Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 5a37b3f

Browse files
committed
Bug fixes
1 parent 7ce3d2d commit 5a37b3f

14 files changed

+156
-143
lines changed

Open in Slide/ActionViewController.swift

+11-5
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ class ActionViewController: UIViewController {
4141

4242
var comps = URLComponents(url: shareURL as URL, resolvingAgainstBaseURL: false)!
4343
comps.scheme = "slide"
44-
let newUrl = comps.url!
45-
46-
if self.openURL(newUrl) {
47-
self.extensionContext!.cancelRequest(withError: NSError())
44+
if let newUrl = comps.url {
45+
if self.openURL(newUrl) {
46+
self.extensionContext!.cancelRequest(withError: NSError())
47+
} else {
48+
self.extensionContext!.cancelRequest(withError: NSError())
49+
}
4850
} else {
49-
self.extensionContext!.cancelRequest(withError: NSError())
51+
if self.openURL(shareURL as URL) {
52+
self.extensionContext!.cancelRequest(withError: NSError())
53+
} else {
54+
self.extensionContext!.cancelRequest(withError: NSError())
55+
}
5056
}
5157
}
5258
})

Slide Widgets/Widgets/FavoriteSubredditsWidget.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct Favorite_Subreddits: Widget {
2929
}
3030
.configurationDisplayName("Subreddit")
3131
.description("Quick links to your favorite Subreddit.")
32+
.supportedFamilies([WidgetFamily.systemMedium, WidgetFamily.systemLarge])
3233
}
3334
}
3435

@@ -93,8 +94,6 @@ struct Favorite_Subreddits_Previews: PreviewProvider {
9394

9495
static var previews: some View {
9596
Group {
96-
Favorite_SubredditsEntryView(entry: SubredditEntry(date: Date(), subreddits: ["all", "frontpage", "popular", "slide_ios"], imageData: getPlaceholderData(["all", "frontpage", "popular", "slide_ios"])))
97-
.previewContext(WidgetPreviewContext(family: .systemSmall))
9897
Favorite_SubredditsEntryView(entry: SubredditEntry(date: Date(), subreddits: ["all", "frontpage", "popular", "slide_ios"], imageData: getPlaceholderData(["all", "frontpage", "popular", "slide_ios"])))
9998
.previewContext(WidgetPreviewContext(family: .systemMedium))
10099
Favorite_SubredditsEntryView(entry: SubredditEntry(date: Date(), subreddits: ["all", "frontpage", "popular", "slide_ios"], imageData: getPlaceholderData(["all", "frontpage", "popular", "slide_ios"])))

Slide for Reddit.xcodeproj/xcuserdata/carloscrane.xcuserdatad/xcschemes/xcschememanagement.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<key>Slide Widgets.xcscheme_^#shared#^_</key>
2828
<dict>
2929
<key>orderHint</key>
30-
<integer>42</integer>
30+
<integer>43</integer>
3131
</dict>
3232
<key>Slide for Apple Watch (Notification).xcscheme</key>
3333
<dict>

Slide for Reddit/AlbumViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class AlbumViewController: SwipeDownModalVC, UIPageViewControllerDataSource, UIP
461461

462462
func pageViewController(_ pageViewController: UIPageViewController,
463463
viewControllerBefore viewController: UIViewController) -> UIViewController? {
464-
guard let viewControllerIndex = urlStringKeys.firstIndex(of: ((viewController as! ModalMediaViewController).embeddedVC.data.baseURL?.absoluteString)!) else {
464+
guard let viewControllerIndex = urlStringKeys.firstIndex(of: ((viewController as! ModalMediaViewController).embeddedVC.data.baseURL?.absoluteString) ?? "") else {
465465
return nil
466466
}
467467

@@ -480,7 +480,7 @@ class AlbumViewController: SwipeDownModalVC, UIPageViewControllerDataSource, UIP
480480

481481
func pageViewController(_ pageViewController: UIPageViewController,
482482
viewControllerAfter viewController: UIViewController) -> UIViewController? {
483-
guard let viewControllerIndex = urlStringKeys.firstIndex(of: ((viewController as! ModalMediaViewController).embeddedVC.data.baseURL?.absoluteString)!) else {
483+
guard let viewControllerIndex = urlStringKeys.firstIndex(of: ((viewController as! ModalMediaViewController).embeddedVC.data.baseURL?.absoluteString) ?? "") else {
484484
return nil
485485
}
486486

Slide for Reddit/AutoCache.swift

+9-8
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,17 @@ public class AutoCache: NSObject {
9797

9898
if !comments.isEmpty {
9999
do {
100-
let realm = try! Realm()
101-
realm.beginWrite()
102-
for comment in comments {
103-
realm.create(type(of: content[comment]!), value: content[comment]!, update: .all)
104-
if content[comment]! is RComment {
105-
link.comments.append(content[comment] as! RComment)
100+
if let realm = try? Realm() {
101+
realm.beginWrite()
102+
for comment in comments {
103+
realm.create(type(of: content[comment]!), value: content[comment]!, update: .all)
104+
if content[comment]! is RComment {
105+
link.comments.append(content[comment] as! RComment)
106+
}
106107
}
108+
realm.create(type(of: link), value: link, update: .all)
109+
try realm.commitWrite()
107110
}
108-
realm.create(type(of: link), value: link, update: .all)
109-
try realm.commitWrite()
110111
} catch {
111112

112113
}

Slide for Reddit/CommentViewController.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,8 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi
16741674
override func viewDidAppear(_ animated: Bool) {
16751675
super.viewDidAppear(animated)
16761676

1677+
refreshControl.setValue(100, forKey: "_snappingHeight")
1678+
16771679
if UIScreen.main.traitCollection.userInterfaceIdiom == .pad && Int(round(self.view.bounds.width / CGFloat(320))) > 1 && false {
16781680
self.navigationController!.view.backgroundColor = .clear
16791681
}

Slide for Reddit/Info.plist

+90-90
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,24 @@
1212
<dict>
1313
<key>CFBundleAlternateIcons</key>
1414
<dict>
15-
<key>black</key>
16-
<dict>
17-
<key>CFBundleIconFiles</key>
18-
<array>
19-
<string>ic_black</string>
20-
</array>
21-
<key>UIPrerenderedIcon</key>
22-
<false/>
23-
</dict>
24-
<key>space</key>
25-
<dict>
26-
<key>CFBundleIconFiles</key>
27-
<array>
28-
<string>ic_space</string>
29-
</array>
30-
<key>UIPrerenderedIcon</key>
31-
<false/>
32-
</dict>
33-
<key>blackwhite</key>
34-
<dict>
35-
<key>CFBundleIconFiles</key>
36-
<array>
37-
<string>ic_blackwhite</string>
38-
</array>
39-
<key>UIPrerenderedIcon</key>
40-
<false/>
41-
</dict>
42-
<key>pride</key>
43-
<dict>
44-
<key>CFBundleIconFiles</key>
45-
<array>
46-
<string>ic_pride</string>
47-
</array>
48-
<key>UIPrerenderedIcon</key>
49-
<false/>
50-
</dict>
15+
<key>black</key>
16+
<dict>
17+
<key>CFBundleIconFiles</key>
18+
<array>
19+
<string>ic_black</string>
20+
</array>
21+
<key>UIPrerenderedIcon</key>
22+
<false/>
23+
</dict>
24+
<key>blackwhite</key>
25+
<dict>
26+
<key>CFBundleIconFiles</key>
27+
<array>
28+
<string>ic_blackwhite</string>
29+
</array>
30+
<key>UIPrerenderedIcon</key>
31+
<false/>
32+
</dict>
5133
<key>blue</key>
5234
<dict>
5335
<key>CFBundleIconFiles</key>
@@ -66,6 +48,15 @@
6648
<key>UIPrerenderedIcon</key>
6749
<false/>
6850
</dict>
51+
<key>garbage</key>
52+
<dict>
53+
<key>CFBundleIconFiles</key>
54+
<array>
55+
<string>ic_garbage</string>
56+
</array>
57+
<key>UIPrerenderedIcon</key>
58+
<false/>
59+
</dict>
6960
<key>ghost</key>
7061
<dict>
7162
<key>CFBundleIconFiles</key>
@@ -120,6 +111,15 @@
120111
<key>UIPrerenderedIcon</key>
121112
<false/>
122113
</dict>
114+
<key>pride</key>
115+
<dict>
116+
<key>CFBundleIconFiles</key>
117+
<array>
118+
<string>ic_pride</string>
119+
</array>
120+
<key>UIPrerenderedIcon</key>
121+
<false/>
122+
</dict>
123123
<key>purple</key>
124124
<dict>
125125
<key>CFBundleIconFiles</key>
@@ -147,6 +147,15 @@
147147
<key>UIPrerenderedIcon</key>
148148
<false/>
149149
</dict>
150+
<key>space</key>
151+
<dict>
152+
<key>CFBundleIconFiles</key>
153+
<array>
154+
<string>ic_space</string>
155+
</array>
156+
<key>UIPrerenderedIcon</key>
157+
<false/>
158+
</dict>
150159
<key>stars</key>
151160
<dict>
152161
<key>CFBundleIconFiles</key>
@@ -183,57 +192,30 @@
183192
<key>UIPrerenderedIcon</key>
184193
<false/>
185194
</dict>
186-
<key>garbage</key>
187-
<dict>
188-
<key>CFBundleIconFiles</key>
189-
<array>
190-
<string>ic_garbage</string>
191-
</array>
192-
<key>UIPrerenderedIcon</key>
193-
<false/>
194-
</dict>
195195
</dict>
196196
</dict>
197197
<key>CFBundleIcons~ipad</key>
198198
<dict>
199199
<key>CFBundleAlternateIcons</key>
200200
<dict>
201-
<key>black</key>
202-
<dict>
203-
<key>CFBundleIconFiles</key>
204-
<array>
205-
<string>ic_black</string>
206-
</array>
207-
<key>UIPrerenderedIcon</key>
208-
<false/>
209-
</dict>
210-
<key>space</key>
211-
<dict>
212-
<key>CFBundleIconFiles</key>
213-
<array>
214-
<string>ic_space</string>
215-
</array>
216-
<key>UIPrerenderedIcon</key>
217-
<false/>
218-
</dict>
219-
<key>pride</key>
220-
<dict>
221-
<key>CFBundleIconFiles</key>
222-
<array>
223-
<string>ic_pride</string>
224-
</array>
225-
<key>UIPrerenderedIcon</key>
226-
<false/>
227-
</dict>
228-
<key>blackwhite</key>
229-
<dict>
230-
<key>CFBundleIconFiles</key>
231-
<array>
232-
<string>ic_blackwhite</string>
233-
</array>
234-
<key>UIPrerenderedIcon</key>
235-
<false/>
236-
</dict>
201+
<key>black</key>
202+
<dict>
203+
<key>CFBundleIconFiles</key>
204+
<array>
205+
<string>ic_black</string>
206+
</array>
207+
<key>UIPrerenderedIcon</key>
208+
<false/>
209+
</dict>
210+
<key>blackwhite</key>
211+
<dict>
212+
<key>CFBundleIconFiles</key>
213+
<array>
214+
<string>ic_blackwhite</string>
215+
</array>
216+
<key>UIPrerenderedIcon</key>
217+
<false/>
218+
</dict>
237219
<key>blue</key>
238220
<dict>
239221
<key>CFBundleIconFiles</key>
@@ -252,6 +234,15 @@
252234
<key>UIPrerenderedIcon</key>
253235
<false/>
254236
</dict>
237+
<key>garbage</key>
238+
<dict>
239+
<key>CFBundleIconFiles</key>
240+
<array>
241+
<string>ic_garbage</string>
242+
</array>
243+
<key>UIPrerenderedIcon</key>
244+
<false/>
245+
</dict>
255246
<key>ghost</key>
256247
<dict>
257248
<key>CFBundleIconFiles</key>
@@ -306,6 +297,15 @@
306297
<key>UIPrerenderedIcon</key>
307298
<false/>
308299
</dict>
300+
<key>pride</key>
301+
<dict>
302+
<key>CFBundleIconFiles</key>
303+
<array>
304+
<string>ic_pride</string>
305+
</array>
306+
<key>UIPrerenderedIcon</key>
307+
<false/>
308+
</dict>
309309
<key>purple</key>
310310
<dict>
311311
<key>CFBundleIconFiles</key>
@@ -333,6 +333,15 @@
333333
<key>UIPrerenderedIcon</key>
334334
<false/>
335335
</dict>
336+
<key>space</key>
337+
<dict>
338+
<key>CFBundleIconFiles</key>
339+
<array>
340+
<string>ic_space</string>
341+
</array>
342+
<key>UIPrerenderedIcon</key>
343+
<false/>
344+
</dict>
336345
<key>stars</key>
337346
<dict>
338347
<key>CFBundleIconFiles</key>
@@ -369,15 +378,6 @@
369378
<key>UIPrerenderedIcon</key>
370379
<false/>
371380
</dict>
372-
<key>garbage</key>
373-
<dict>
374-
<key>CFBundleIconFiles</key>
375-
<array>
376-
<string>ic_garbage</string>
377-
</array>
378-
<key>UIPrerenderedIcon</key>
379-
<false/>
380-
</dict>
381381
</dict>
382382
</dict>
383383
<key>CFBundleIdentifier</key>

Slide for Reddit/MainViewController.swift

+8-3
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ class MainViewController: ColorMuxPagingViewController, UINavigationControllerDe
167167
}
168168

169169
func checkSubs() {
170+
let currentAccount = AccountController.currentName
170171
if let session = (UIApplication.shared.delegate as! AppDelegate).session {
171172
Subscriptions.getSubscriptionsFully(session: session, completion: { (newSubs, newMultis) in
172-
if AccountController.isLoggedIn {
173+
if AccountController.isLoggedIn && currentAccount == AccountController.currentName { //Ensure the user did not switch accounts before applying subs
173174
var allSubs = [String]()
174175
allSubs.append(contentsOf: newSubs.map { $0.displayName })
175176
allSubs.append(contentsOf: newMultis.map { "/m/" + $0.displayName })
@@ -181,7 +182,7 @@ class MainViewController: ColorMuxPagingViewController, UINavigationControllerDe
181182
finalSubs.append(sub)
182183
}
183184
}
184-
Subscriptions.set(name: AccountController.currentName, subs: finalSubs, completion: {
185+
Subscriptions.set(name: currentAccount, subs: finalSubs, completion: {
185186
})
186187
}
187188
})
@@ -580,6 +581,10 @@ class MainViewController: ColorMuxPagingViewController, UINavigationControllerDe
580581
didUpdate()
581582
}
582583

584+
@objc public func handleCloseNav(controller: UIButtonWithContext) {
585+
controller.parentController?.dismiss(animated: true, completion: nil)
586+
}
587+
583588
func checkForUpdate() {
584589
if !SettingValues.doneVersion() {
585590
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2) {
@@ -598,7 +603,7 @@ class MainViewController: ColorMuxPagingViewController, UINavigationControllerDe
598603
button.imageView?.contentMode = UIView.ContentMode.scaleAspectFit
599604
button.setImage(UIImage(sfString: SFSymbol.xmark, overrideString: "close")!.navIcon(), for: UIControl.State.normal)
600605
button.frame = CGRect.init(x: 0, y: 0, width: 40, height: 40)
601-
button.addTarget(self, action: #selector(VCPresenter.handleCloseNav(controller:)), for: .touchUpInside)
606+
button.addTarget(self, action: #selector(self.handleCloseNav(controller:)), for: .touchUpInside)
602607

603608
let barButton = UIBarButtonItem.init(customView: button)
604609
barButton.customView?.frame = CGRect.init(x: 0, y: 0, width: 40, height: 40)

0 commit comments

Comments
 (0)