Skip to content

Commit

Permalink
Regression fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flypaper0 committed Jan 29, 2024
1 parent c2d5d6b commit 28f667e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ final class SubscriptionPresenter: ObservableObject {
case .idle:
Task(priority: .high) { @MainActor in
loadingState = .loading
isMoreDataAvailable = try await interactor.fetchHistory(after: messages.last?.id, limit: 50)
let isLoaded = try? await interactor.fetchHistory(after: messages.last?.id, limit: 50)
isMoreDataAvailable = isLoaded ?? false
loadingState = .idle
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct SubscriptionView: View {
private func notificationView(pushMessage: NotifyMessageViewModel) -> some View {
VStack(alignment: .center) {
HStack(spacing: 12) {
CacheAsyncImage(url: URL(string: pushMessage.imageUrl)) { phase in
CacheAsyncImage(url: URL(string: pushMessage.imageUrl) ?? presenter.subscriptionViewModel.imageUrl) { phase in
if let image = phase.image {
image
.resizable()
Expand All @@ -58,6 +58,7 @@ struct SubscriptionView: View {
.cornerRadius(10, corners: .allCorners)
} else {
Color.black
.opacity(0.05)
.frame(width: 48, height: 48)
.cornerRadius(10, corners: .allCorners)
}
Expand Down
13 changes: 10 additions & 3 deletions Sources/Database/SQLiteQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public struct SqliteQuery {

for row in rows {
values.append(row.encode().values
.map { "'\($0.value)'" }
.map { "'\($0.value.screen())'" }
.joined(separator: ", "))
}

Expand All @@ -34,15 +34,15 @@ public struct SqliteQuery {
}

public static func select(table: String, where argument: String, equals value: String) -> String {
return "SELECT * FROM \(table) WHERE \(argument) = '\(value)';"
return "SELECT * FROM \(table) WHERE \(argument) = '\(value.screen())';"
}

public static func delete(table: String) -> String {
return "DELETE FROM \(table);"
}

public static func delete(table: String, where argument: String, equals value: String) -> String {
return "DELETE FROM \(table) WHERE \(argument) = '\(value)';"
return "DELETE FROM \(table) WHERE \(argument) = '\(value.screen())';"
}
}

Expand All @@ -52,3 +52,10 @@ extension SqliteQuery {
case rowsNotFound
}
}

private extension String {

func screen() -> String {
return replacingOccurrences(of: "'", with: "''")
}
}

0 comments on commit 28f667e

Please sign in to comment.