Skip to content

Commit

Permalink
Quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinark committed Oct 28, 2023
1 parent d9b99d8 commit 08fae5e
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 89 deletions.
19 changes: 5 additions & 14 deletions TestFlight/WhatToTest.en-US.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
--- QUICK EXPRESS UPDATE ---
- Fixes a major performance issue that I hadn't notice before
- Fixes flair tag centered again
- Tries to fix a few remaining errors related to themes
--- QUICK EXPRESS UPDATE ---
- Fixed crash when replying
- Fixed crash when importing new themes
- Fixed crash when long pressing on comment
- Fixed random name in exported themes
- Now exported themes have ".winston" extension (zip will continue to work though)
- Sharing zip to winston is now allowed
- ".winston" open in one tap into winston and imports it
- Fixed subs not showing up in multis
- Fixed centered tags in post links
A big update is coming soon, sorry for the wait.

--- QUICK EXPRESS UPDATE ---
- Fixed subs order
- Fixed subs filtering
- Fixed favoriting subs not working properly
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire.git",
"state" : {
"revision" : "bc268c28fb170f494de9e9927c371b8342979ece",
"version" : "5.7.1"
"revision" : "b2fa556e4e48cbf06cf8c63def138c98f4b811fa",
"version" : "5.8.0"
}
},
{
Expand All @@ -15,7 +15,7 @@
"location" : "https://github.com/ImTheSquid/AlertToast.git",
"state" : {
"branch" : "master",
"revision" : "1e5e30f68860b7b5ea7cadd51ced166dfe486bca"
"revision" : "9e74dd700c9ab459e46efb65cf508c543cb54f42"
}
},
{
Expand Down Expand Up @@ -51,7 +51,7 @@
"location" : "https://github.com/sindresorhus/Defaults",
"state" : {
"branch" : "main",
"revision" : "bd14dae265091c5fb1ba1123a52861ae9f2ede84"
"revision" : "d8a9f5105607c85b544558e7f5b51d6c360ba88b"
}
},
{
Expand All @@ -77,8 +77,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kyle-n/HighlightedTextEditor",
"state" : {
"revision" : "7069ede002afc6bde867aef7035f45ff72dc839c",
"version" : "2.1.0"
"revision" : "759d7b4bd2c10d0bbe93bc62d68572a3702049e3",
"version" : "2.1.2"
}
},
{
Expand All @@ -95,8 +95,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kean/Nuke.git",
"state" : {
"revision" : "29d3a7e0c687f97fe35b584f60b93fc547d3dade",
"version" : "12.1.5"
"revision" : "3f666f120b63ea7de57d42e9a7c9b47f8e7a290b",
"version" : "12.1.6"
}
},
{
Expand Down Expand Up @@ -149,8 +149,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "dc46eeb3928a75390651fac6c1ef7f93ad59a73b",
"version" : "1.11.1"
"revision" : "bb0ea08db8e73324fe6c3727f755ca41a23ff2f4",
"version" : "1.14.2"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
}
},
{
Expand All @@ -167,8 +176,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/swiftui-introspect",
"state" : {
"revision" : "6dce3c8f5bfa8bc20120c7497da27e984a8813aa",
"version" : "0.7.0"
"revision" : "121c146fe591b1320238d054ae35c81ffa45f45a",
"version" : "0.12.0"
}
},
{
Expand All @@ -185,8 +194,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/SvenTiigi/YouTubePlayerKit.git",
"state" : {
"revision" : "6bbba75c8a8927e8073765849e22707d96b55205",
"version" : "1.5.2"
"revision" : "1fe4c8b07a61d50c2fd276e1d9c8087583c7638a",
"version" : "1.5.3"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions winston/Tabber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ struct Tabber: View {
, alignment: .bottom
)
.overlay(
tabBarHeight.isNil
tabBarHeight == nil
? nil
: TabBarOverlay(router: payload[activeTab]!.router, tabHeight: tabHeight, meTabTap: meTabTap).id(payload[activeTab]!.router.id)
, alignment: .bottom
)
.background(OFWOpener(router: payload[TabIdentifier.posts]!.router))
.fullScreenCover(isPresented: Binding(get: { !tempGlobalState.inAppBrowserURL.isNil }, set: { val in
.fullScreenCover(isPresented: Binding(get: { tempGlobalState.inAppBrowserURL != nil }, set: { val in
tempGlobalState.inAppBrowserURL = nil
})) {
if let url = tempGlobalState.inAppBrowserURL {
Expand Down
2 changes: 1 addition & 1 deletion winston/components/LightBoxImage/LightBoxImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct LightBoxImage: View {
: DragGesture(minimumDistance: 20)
.onChanged { val in

if dragAxis.isNil || dragOffset.isNil {
if dragAxis == nil || dragOffset == nil {
dragOffset = val.translation
if abs(val.predictedEndTranslation.width) > abs(val.predictedEndTranslation.height) {
dragAxis = .horizontal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ struct CommentLinkContent: View {
Text(body.md())
.lineLimit(lineLimit)
} else {
MD(data.winstonBodyAttrEncoded.isNil ? .str(body) : .json(data.winstonBodyAttrEncoded!), fontSize: theme.theme.bodyText.size)
MD(data.winstonBodyAttrEncoded == nil ? .str(body) : .json(data.winstonBodyAttrEncoded!), fontSize: theme.theme.bodyText.size)
.fixedSize(horizontal: false, vertical: true)
.overlay(
!selectable
Expand Down
2 changes: 1 addition & 1 deletion winston/components/Links/PostInBoxLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct PostInBoxLink: View {
var endingY: CGFloat = 0
let endPos = dragVal?.translation.height ?? 0
let predictedEnd = dragVal?.predictedEndTranslation.height ?? 0
if !dragVal.isNil {
if dragVal != nil {
if predictedEnd > 300 || (endPos > 70 && predictedEnd > 0) { endingY = 300 }
if predictedEnd < -300 || (endPos < 70 && predictedEnd < 0) { endingY = -300 }
}
Expand Down
4 changes: 2 additions & 2 deletions winston/components/Links/PostLink/FlairTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct FlairTag: View {
Text(text)
.padding(.vertical, 2)
}
.fontSize(13, data.isNil ? .regular : .semibold)
.padding(.leading, data.isNil ? 9 : 0)
.fontSize(13, data == nil ? .regular : .semibold)
.padding(.leading, data == nil ? 9 : 0)
.padding(.trailing, 9)
.background(Capsule(style: .continuous).fill(color.opacity(0.2)))
.foregroundColor(.primary.opacity(0.5))
Expand Down
6 changes: 3 additions & 3 deletions winston/components/Links/PostLink/getPostContentWidth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct PostDimensions: Hashable, Equatable {
var size: CGSize {

let compactVSpacing = self.spacingHeight / 2
let tagHeight = urlTagHeight.isNil ? 0 : (compactVSpacing / 2) + (self.urlTagHeight ?? 0)
let tagHeight = urlTagHeight == nil ? 0 : (compactVSpacing / 2) + (self.urlTagHeight ?? 0)
let compactHeight = max(self.titleSize.height + compactVSpacing + self.badgeSize.height + tagHeight, (mediaSize?.height ?? 0)) + dividerSize.height + compactVSpacing
let normalHeight = self.titleSize.height + (self.bodySize?.height ?? 0) + (self.mediaSize?.height ?? 0) + self.dividerSize.height + self.badgeSize.height + self.spacingHeight
return CGSize(
Expand Down Expand Up @@ -137,7 +137,7 @@ func getPostDimensions(post: Post, columnWidth: Double = UIScreen.screenWidth, s
}


let compactTitleWidth = postGeneralSpacing + VotesCluster.verticalWidth + (extractedMedia.isNil ? 0 : postGeneralSpacing + compactMediaSize.width)
let compactTitleWidth = postGeneralSpacing + VotesCluster.verticalWidth + (extractedMedia == nil ? 0 : postGeneralSpacing + compactMediaSize.width)
let titleContentWidth = contentWidth - (compact ? compactTitleWidth : 0)

ACC_titleHeight = round(NSString(string: title).boundingRect(with: CGSize(width: titleContentWidth, height: .infinity), options: [.usesLineFragmentOrigin], attributes: [.font: UIFont.systemFont(ofSize: theme.titleText.size, weight: theme.titleText.weight.ut)], context: nil).height)
Expand All @@ -164,7 +164,7 @@ func getPostDimensions(post: Post, columnWidth: Double = UIScreen.screenWidth, s

let theresTitle = true
let theresSelftext = !compact && !data.selftext.isEmpty
let theresMedia = !extractedMedia.isNil
let theresMedia = extractedMedia != nil
let theresSubDivider = true
let theresBadge = true
let elements = [theresTitle, theresSelftext, !compact && theresMedia, theresSubDivider, theresBadge]
Expand Down
2 changes: 1 addition & 1 deletion winston/components/Media/ImageMediaPost/GalleryThumb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct GalleryThumb: View, Equatable {
.scaledToFill()
.zIndex(1)
.allowsHitTesting(false)
.fixedSize(horizontal: false, vertical: height.isNil)
.fixedSize(horizontal: false, vertical: height == nil)
.frame(width: width, height: height)
.clipped()
.mask(RR(selectedTheme.postLinks.theme.mediaCornerRadius, Color.black))
Expand Down
2 changes: 1 addition & 1 deletion winston/components/Media/PreviewLink/PreviewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class PreviewModel: ObservableObject {

var previewURL: URL? {
didSet {
if !previewURL.isNil { fetchMetadata() }
if previewURL != nil { fetchMetadata() }
}
}

Expand Down
2 changes: 1 addition & 1 deletion winston/components/Media/RedditMediaPost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ThingEntityCache: ObservableObject {
@Published var thingEntities: [RedditURLType:ThingType] = [:]

func load(_ thing: RedditURLType, redditAPI: RedditAPI) {
if !thingEntities[thing].isNil { return }
if thingEntities[thing] != nil { return }
Task(priority: .background) {
switch thing {
case .comment(let id, _, _):
Expand Down
8 changes: 4 additions & 4 deletions winston/components/Media/VideoPlayerPost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SharedVideoCache: ObservableObject {
let cacheLimit = 35

func addKeyValue(key: String, url: URL, size: CGSize) {
if !cache[key].isNil { return }
if cache[key] != nil { return }
Task(priority: .background) {
// Create a new CacheItem with the current date
let video = SharedVideo(url: url, size: size)
Expand Down Expand Up @@ -225,8 +225,8 @@ struct FullScreenVP: View {
? nil
: DragGesture(minimumDistance: 10)
.onChanged { val in
if cancelDrag.isNil { cancelDrag = abs(val.translation.width) > abs(val.translation.height) }
if cancelDrag.isNil || cancelDrag! { return }
if cancelDrag == nil { cancelDrag = abs(val.translation.width) > abs(val.translation.height) }
if cancelDrag == nil || cancelDrag! { return }
var transaction = Transaction()
transaction.isContinuous = true
transaction.animation = .interpolatingSpring(stiffness: 1000, damping: 100, initialVelocity: 0)
Expand All @@ -239,7 +239,7 @@ struct FullScreenVP: View {
.onEnded { val in
let prevCancelDrag = cancelDrag
cancelDrag = nil
if prevCancelDrag.isNil || prevCancelDrag! { return }
if prevCancelDrag == nil || prevCancelDrag! { return }
let shouldClose = abs(val.translation.width) > 100 || abs(val.translation.height) > 100
withAnimation(.interpolatingSpring(stiffness: 200, damping: 20, initialVelocity: 0)) {
drag = .zero
Expand Down
2 changes: 1 addition & 1 deletion winston/components/OFWOpener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct OFWOpener: View {
var body: some View {
EmptyView()
.onChange(of: router.path) { _ in
if !OpenFromWeb.shared.data.isNil {
if OpenFromWeb.shared.data != nil {
OpenFromWeb.shared.data = nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion winston/components/SubredditPostsIOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct SubredditPostsIOS: View, Equatable {
.listRowBackground(Color.clear)

Section {
if !lastPostAfter.isNil {
if lastPostAfter != nil {
ProgressView()
.progressViewStyle(.circular)
.frame(maxWidth: .infinity, minHeight: posts.count > 0 ? 100 : UIScreen.screenHeight - 200 )
Expand Down
2 changes: 1 addition & 1 deletion winston/models/RedditAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RedditAPI: ObservableObject {
}

func refreshToken(_ force: Bool = false, count: Int = 0) async -> Void {
if force || loggedUser.lastRefresh.isNil {
if force || loggedUser.lastRefresh == nil {
await MainActor.run {
loggedUser.lastRefresh = Date(seconds: Date().timeIntervalSince1970 - Double(loggedUser.expiration ?? 86400 * 10))
}
Expand Down
2 changes: 1 addition & 1 deletion winston/models/RedditAPI/post/hidePost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private class HideDebouncer {
extension RedditAPI {
func hidePost(_ hide: Bool, fullnames: [String]) async -> () {
HideDebouncer.shared.names += fullnames
if !HideDebouncer.shared.workItem.isNil { return }
if HideDebouncer.shared.workItem != nil { return }
HideDebouncer.shared.workItem = DispatchWorkItem {
HideDebouncer.shared.workItem = nil
let names = HideDebouncer.shared.names
Expand Down
2 changes: 1 addition & 1 deletion winston/models/RedditAPI/subs/fetchSubs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extension RedditAPI {
if let fetchedSubs = data.data?.children {
finalSubs += fetchedSubs
}
if !after.isNil {
if after != nil {
return finalSubs
}

Expand Down
18 changes: 12 additions & 6 deletions winston/models/Subreddit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,23 @@ extension Subreddit {
}

func favoriteToggle(entity: CachedSub? = nil) {
if let favoritedStatus = data?.user_has_favorited, let name = data?.display_name {

if let entity = entity, let context = entity.managedObjectContext {
if let entity = entity, let name = data?.display_name {
let favoritedStatus = entity.user_has_favorited
if let context = entity.managedObjectContext {
entity.user_has_favorited = !favoritedStatus
try? context.save()
withAnimation {
self.data?.user_has_favorited = !favoritedStatus
try? context.save()
}

Task {
let result = await RedditAPI.shared.favorite(!favoritedStatus, subName: name)
if !result {
entity.user_has_favorited = favoritedStatus
try? context.save()
withAnimation {
self.data?.user_has_favorited = favoritedStatus
try? context.save()
}
}
}
}
Expand All @@ -69,7 +75,7 @@ extension Subreddit {
let context = PersistenceController.shared.container.viewContext

if let data = data {
func doToggle() {
@Sendable func doToggle() {
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "CachedSub")
guard let results = (context.performAndWait { return try? context.fetch(fetchRequest) as? [CachedSub] }) else { return }
let foundSub = context.performAndWait { results.first(where: { $0.name == self.data?.name }) }
Expand Down
4 changes: 2 additions & 2 deletions winston/models/caches/BaseCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BaseCache<T: Any>: ObservableObject {
}

func addKeyValue(key: String, data: @escaping () -> T) {
if !cache[key].isNil { return }
if cache[key] != nil { return }
Task(priority: .background) {
let itemData = data()
// Create a new CacheItem with the current date
Expand Down Expand Up @@ -68,7 +68,7 @@ class BaseObservableCache<T: ObservableObject>: ObservableObject {
}

func addKeyValue(key: String, data: @escaping () -> T) {
if !cache[key].isNil { return }
if cache[key] != nil { return }
Task(priority: .background) {
let itemData = data()
// Create a new CacheItem with the current date
Expand Down
2 changes: 1 addition & 1 deletion winston/modifiers/PinchToZoom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PinchZoomView: UIView, UIGestureRecognizerDelegate {
panGesture = newPanGesture
addGestureRecognizer(newPanGesture)

if !onTap.isNil {
if onTap != nil {
let doubleTap = UIShortTapGestureRecognizer(target: self, action: #selector(doubleTap(gesture:)))
doubleTap.numberOfTapsRequired = 2
addGestureRecognizer(doubleTap)
Expand Down
2 changes: 1 addition & 1 deletion winston/modifiers/SwipeAnywhere.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct SwipeAnywhere: ViewModifier {
? nil
: DragGesture()
.updating($dragState) { val, state, trans in
if state.dragging.isNil { state.dragging = abs(val.translation.width) > abs(val.translation.height) }
if state.dragging == nil { state.dragging = abs(val.translation.width) > abs(val.translation.height) }
guard let dragging = state.dragging, dragging else { return }
let translation = val.translation
trans.isContinuous = true
Expand Down
4 changes: 2 additions & 2 deletions winston/modifiers/subtleSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct SubtleSheetModifier<T: View>: ViewModifier {

func body(content: Content) -> some View {
let dragOffset = dragOffsetRaw ?? 0
let isDragging = !initialDragOffset.isNil
let isDragging = initialDragOffset != nil
let disabled = abs(sheetContentSize.height - forcedOffset) < 2
let interpolate = interpolatorBuilder([handlerDashWidth, 0], value: abs(sheetContentSize.height - forcedOffset))
let dragGesture = DragGesture(minimumDistance: 0)
Expand Down Expand Up @@ -130,7 +130,7 @@ struct SubtleSheetModifier<T: View>: ViewModifier {
.opacity(disappear ? 0 : 1)
.offset(y: disappear ? handlerHeight : 0)
.onAppear { doThisAfter(0.3) { withAnimation(spring) { disappear = false } } }
.onChange(of: dragOffsetRaw.isNil) { newValue in if newValue { initialDragOffset = nil } }
.onChange(of: dragOffsetRaw == nil) { newValue in if newValue { initialDragOffset = nil } }
, alignment: .bottom
)
}
Expand Down
Loading

0 comments on commit 08fae5e

Please sign in to comment.