Skip to content

Commit

Permalink
Merge pull request weiran#230 from weiran/crash-fix
Browse files Browse the repository at this point in the history
Fix comments crash
  • Loading branch information
weiran authored Apr 4, 2022
2 parents 6eb7068 + 1b6e3e7 commit 68d8f85
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window?.rootViewController = mainSplitViewController
window?.tintColor = AppTheme.default.appTintColor
window?.makeKeyAndVisible()

if ProcessInfo.processInfo.arguments.contains("darkMode") {
window?.overrideUserInterfaceStyle = .dark
}
Expand Down
2 changes: 1 addition & 1 deletion App/Comments/CommentsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ extension CommentsViewController {
contextMenuConfigurationForRowAt indexPath: IndexPath,
point: CGPoint
) -> UIContextMenuConfiguration? {
guard let comment = comments?[indexPath.row], let post = post else { return nil }
guard let comment = comments?[safe: indexPath.row], let post = post else { return nil }
let actionOnPost = indexPath.section == 0
let upvoted = actionOnPost ? post.upvoted : comment.upvoted

Expand Down
15 changes: 15 additions & 0 deletions App/Extensions/CollectionExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// CollectionExtensions.swift
// Hackers
//
// Created by Weiran Zhang on 01/01/2022.
// Copyright © 2022 Glass Umbrella. All rights reserved.
//

import Foundation

extension Collection where Indices.Iterator.Element == Index {
subscript (safe index: Index) -> Iterator.Element? {
return indices.contains(index) ? self[index] : nil
}
}
3 changes: 3 additions & 0 deletions App/Services/OnboardingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import WhatsNewKit

enum OnboardingService {
static func onboardingViewController(forceShow: Bool = false) -> UIViewController? {
// disable "whats new" for bugfix releases
return nil

if ProcessInfo.processInfo.arguments.contains("disableOnboarding"), forceShow == false {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions Extensions/HackersActionExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>4.6.6</string>
<string>4.6.7</string>
<key>CFBundleVersion</key>
<string>108</string>
<string>109</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
4 changes: 2 additions & 2 deletions Extensions/HackersShareExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>4.6.6</string>
<string>4.6.7</string>
<key>CFBundleVersion</key>
<string>108</string>
<string>109</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
12 changes: 8 additions & 4 deletions Hackers.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
2419D038248AB03700740184 /* OpenInViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2419D035248AAFDF00740184 /* OpenInViewController.swift */; };
241C32DE24950C05000876DC /* PostTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 241C32DD24950C05000876DC /* PostTitleView.swift */; };
243271951F95EDA9008196DB /* StringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 243271941F95EDA9008196DB /* StringExtensions.swift */; };
243C182B2780A8370018359D /* CollectionExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 243C182A2780A8370018359D /* CollectionExtensions.swift */; };
245345EF22466EA8001AF1CE /* HackersUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 245345EE22466EA8001AF1CE /* HackersUITests.swift */; };
245345FB22466F75001AF1CE /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 245345F722466F71001AF1CE /* SnapshotHelper.swift */; };
2454B9041F655426005A98C7 /* EmptyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2454B9031F655426005A98C7 /* EmptyViewController.swift */; };
Expand Down Expand Up @@ -134,6 +135,7 @@
241C32DD24950C05000876DC /* PostTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostTitleView.swift; sourceTree = "<group>"; };
241E4036253B103100E3ED18 /* Hackers.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Hackers.entitlements; sourceTree = "<group>"; };
243271941F95EDA9008196DB /* StringExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtensions.swift; sourceTree = "<group>"; };
243C182A2780A8370018359D /* CollectionExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionExtensions.swift; sourceTree = "<group>"; };
245345EC22466EA8001AF1CE /* HackersUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HackersUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
245345EE22466EA8001AF1CE /* HackersUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HackersUITests.swift; sourceTree = "<group>"; };
245345F022466EA8001AF1CE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -345,6 +347,7 @@
24FFFF5923362C7800D009EF /* HackersKitExtensions.swift */,
24D1846024B396BD0017E4F4 /* UIViewController+Deselection.swift */,
24E390A92542D7A9000DA7A8 /* UIViewControllerExtensions.swift */,
243C182A2780A8370018359D /* CollectionExtensions.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -952,6 +955,7 @@
2464D21F209E27FE00C7F8FC /* UserDefaultsExtensions.swift in Sources */,
24CE5FF819435A90009D2677 /* PostCell.swift in Sources */,
24B982DF22BE65FF000D8913 /* SettingsStore.swift in Sources */,
243C182B2780A8370018359D /* CollectionExtensions.swift in Sources */,
24628BAD21E6897700BDEEF9 /* AppFont.swift in Sources */,
2457F04524696EB000F3E7A4 /* HackersKit.swift in Sources */,
24A13DC92621F36F002235A8 /* ItemCell.swift in Sources */,
Expand Down Expand Up @@ -1320,15 +1324,15 @@
CODE_SIGN_ENTITLEMENTS = "App/Supporting Files/Hackers.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 109;
DEVELOPMENT_TEAM = 2KB59GPA9B;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "App/Supporting Files/Hackers2-Prefix.pch";
INFOPLIST_FILE = "App/Supporting Files/Hackers-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.6.6;
MARKETING_VERSION = 4.6.7;
PRODUCT_BUNDLE_IDENTIFIER = "com.weiranzhang.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Hackers;
PROVISIONING_PROFILE_SPECIFIER = "Hackers Dev Profile";
Expand All @@ -1350,15 +1354,15 @@
CODE_SIGN_ENTITLEMENTS = "App/Supporting Files/Hackers.entitlements";
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 109;
DEVELOPMENT_TEAM = 2KB59GPA9B;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "App/Supporting Files/Hackers2-Prefix.pch";
INFOPLIST_FILE = "App/Supporting Files/Hackers-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.6.6;
MARKETING_VERSION = 4.6.7;
PRODUCT_BUNDLE_IDENTIFIER = "com.weiranzhang.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Hackers;
PROVISIONING_PROFILE_SPECIFIER = "Hackers Prod Profile";
Expand Down
22 changes: 11 additions & 11 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PODS:
- BulletinBoard (5.0.0)
- DeviceKit (4.5.2)
- DeviceKit (4.6.0)
- HNScraper (0.2.2)
- Loaf (0.7.0)
- Nuke (10.6.1)
- PromiseKit/CorePromise (6.15.3)
- SwiftLint (0.45.1)
- SwiftSoup (2.3.4)
- Nuke (10.7.1)
- PromiseKit/CorePromise (6.17.0)
- SwiftLint (0.46.5)
- SwiftSoup (2.3.8)
- Swinject (2.7.1)
- SwinjectStoryboard (2.2.2):
- Swinject (~> 2.7.1)
Expand Down Expand Up @@ -53,18 +53,18 @@ CHECKOUT OPTIONS:

SPEC CHECKSUMS:
BulletinBoard: dba77053c2a7b64953f63073f7534165af2edd21
DeviceKit: c622fc19f795f3e0b4d75d6d11b26604338cdab3
DeviceKit: 834dd8aa1be53cd85364d8f49aa5d98bfac397c4
HNScraper: d96632c361238905f2886f83675e75f2153b4dc4
Loaf: d69937cd00649f3fa260beb8b7aef0a1feb861ef
Nuke: 3ca210aee6d90756605c5125cbe40569fd9c06f7
PromiseKit: 3b2b6995e51a954c46dbc550ce3da44fbfb563c5
SwiftLint: 06ac37e4d38c7068e0935bb30cda95f093bec761
SwiftSoup: d5b9645498f8d09fdc5f96b9c70b5858099fd411
Nuke: 279f17a599fd1c83cf51de5e0e1f2db143a287b0
PromiseKit: 996202d4cae72b7801b312abef4cd2f995b2978a
SwiftLint: 2c16e8fa99dac2e440dc0c70ea74d2532048f6cf
SwiftSoup: ba8ea2c91151881a298cba4b0628ef31e835a77f
Swinject: ddf78b8486dd9b71a667b852cad919ab4484478e
SwinjectStoryboard: 240ce371396da09a4c43c72ee5c148108500e184
SwipeCellKit: 3972254a826da74609926daf59b08d6c72e619ea
WhatsNewKit: c87028c4059dccd113495422801914cc53f6aab0

PODFILE CHECKSUM: 01446ada016a8c363277039b82b7b1c2962beffe

COCOAPODS: 1.11.2
COCOAPODS: 1.11.3

0 comments on commit 68d8f85

Please sign in to comment.