Skip to content

Commit

Permalink
Network Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakr233 committed May 8, 2023
1 parent 3e4c25e commit d4a5667
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Foundation/Source/Sources/Module/RemoteNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class RemoteNotification: Codable, Identifiable, Hashable, Equatable {
public let noteId: String?
public let reaction: String?

public init(notificationId: String, createdAt: Date, isRead: Bool, type: RemoteNotification.Kind, userId: String? = nil, noteId: String? = nil, reaction: String? = nil) {
public init(notificationId: String, createdAt: Date, isRead: Bool = false, type: RemoteNotification.Kind, userId: String? = nil, noteId: String? = nil, reaction: String? = nil) {
self.notificationId = notificationId
self.createdAt = createdAt
self.isRead = isRead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public extension RemoteNotification {
return RemoteNotification(
notificationId: notification.id,
createdAt: date,
isRead: notification.isRead,
isRead: notification.isRead ?? false,
type: type,
userId: notification.userId,
noteId: notification.note?.id,
Expand Down
10 changes: 9 additions & 1 deletion Foundation/Source/Sources/Network/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public extension Network {

func makeRequest(
with request: URLRequest,
with session: URLSession = .shared,
with session: URLSession = .newEphemeral(),
setTask: (URLSessionDataTask) -> Void = { _ in },
completion: @escaping (Data) -> Void
) {
Expand Down Expand Up @@ -296,3 +296,11 @@ public extension Network {
return object
}
}

public extension URLSession {
static func newEphemeral() -> URLSession {
let config = URLSessionConfiguration.ephemeral
let session = URLSession(configuration: config)
return session
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
public struct NMNotification: Codable {
public let id: String
public let createdAt: String
public let isRead: Bool
public let isRead: Bool?
public let type: NotificationType

public enum NotificationType: String, Codable {
Expand Down
22 changes: 11 additions & 11 deletions Foundation/Source/Tests/SourceTest/SourceTest+Meta.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ private extension Network.RequestTarget {
case .account_i: return SourceTest.test_201_api_user.self

case .i_favorites: return SourceTest.test_202_api_i_favorites.self
case .i_notification: return SourceTest.test_203_api_i_notification.self
case .i_notification: return SourceTest.test_204_api_i_notification.self

case .following_create: return SourceTest.test_204_api_following.self
case .following_delete: return SourceTest.test_204_api_following.self
case .following_requests_accept: return SourceTest.test_204_api_following.self
case .following_requests_reject: return SourceTest.test_204_api_following.self
case .following_requests_cancel: return SourceTest.test_204_api_following.self
case .following_invalidate: return SourceTest.test_204_api_following.self
case .following_create: return SourceTest.test_203_api_following.self
case .following_delete: return SourceTest.test_203_api_following.self
case .following_requests_accept: return SourceTest.test_203_api_following.self
case .following_requests_reject: return SourceTest.test_203_api_following.self
case .following_requests_cancel: return SourceTest.test_203_api_following.self
case .following_invalidate: return SourceTest.test_203_api_following.self

case .users: return SourceTest.test_204_api_following.self
case .users: return SourceTest.test_203_api_following.self
case .users_report_abuse: return SourceTest.test_215_report_abuse.self
case .user_show: return SourceTest.test_204_api_following.self
case .users_followers: return SourceTest.test_204_api_following.self
case .users_following: return SourceTest.test_204_api_following.self
case .user_show: return SourceTest.test_203_api_following.self
case .users_followers: return SourceTest.test_203_api_following.self
case .users_following: return SourceTest.test_203_api_following.self

case .user_notes: return SourceTest.test_205_api_user.self

Expand Down
8 changes: 4 additions & 4 deletions Foundation/Source/Tests/SourceTest/SourceTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ class SourceTest: XCTestCase {
checkApi_Favorite()
}

func test_203_api_i_notification() {
checkApi_Notification()
func test_203_api_following() {
checkApi_Following()
}

func test_204_api_following() {
checkApi_Following()
func test_204_api_i_notification() {
checkApi_Notification()
}

func test_205_api_user() {
Expand Down
2 changes: 1 addition & 1 deletion Foundation/Source/Tests/SourceTest/Tests/Login.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extension SourceTest {
"session": challenge.requestSession,
"permission": permission,
"i": firstToken,
]) else {
] as [String: Any]) else {
XCTFail("unable to create data")
return nil
}
Expand Down
12 changes: 7 additions & 5 deletions Kimis.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
5069EBC4295EEAD100677A3F /* UserPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPreview.swift; sourceTree = "<group>"; };
5080C6A3297EC3B300F73CCD /* Launcher.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Launcher.storyboard; sourceTree = "<group>"; };
50831AAA296AB77F002A166A /* TableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = "<group>"; };
508AC67329E8EBF100342409 /* KimisDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = KimisDebug.entitlements; sourceTree = "<group>"; };
508FC8292962C16F00B032D8 /* PostEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostEditorView.swift; sourceTree = "<group>"; };
508FC82B296328AD00B032D8 /* CGRect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGRect.swift; sourceTree = "<group>"; };
508FC82D296329F900B032D8 /* CGSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGSize.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1012,6 +1013,7 @@
children = (
50BED14129277CDF00C9D7E2 /* Info.plist */,
50BED14729277D0D00C9D7E2 /* Kimis.entitlements */,
508AC67329E8EBF100342409 /* KimisDebug.entitlements */,
50BED19C29277D0E00C9D7E2 /* App */,
50BED16A29277D0E00C9D7E2 /* Interface */,
50BED1A129277D0E00C9D7E2 /* Backend */,
Expand Down Expand Up @@ -1858,10 +1860,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = Kimis/Kimis.entitlements;
CODE_SIGN_ENTITLEMENTS = Kimis/KimisDebug.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 111;
CURRENT_PROJECT_VERSION = 130;
DEVELOPMENT_TEAM = 6CMYQQFFT8;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -1879,7 +1881,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.11;
MARKETING_VERSION = 1.13;
PRODUCT_BUNDLE_IDENTIFIER = wiki.qaq.kimis.inhouse;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand All @@ -1900,7 +1902,7 @@
CODE_SIGN_ENTITLEMENTS = Kimis/Kimis.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 111;
CURRENT_PROJECT_VERSION = 130;
DEVELOPMENT_TEAM = 6CMYQQFFT8;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -1918,7 +1920,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.11;
MARKETING_VERSION = 1.13;
PRODUCT_BUNDLE_IDENTIFIER = as.wiki.qaq.kimis;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
12 changes: 6 additions & 6 deletions Kimis.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/bugsnag/bugsnag-cocoa",
"state" : {
"revision" : "5be1c4c544752c90774cf5b464683064a5bb1015",
"version" : "6.26.1"
"revision" : "c730af7a4676617d82394782300df997d9a356cd",
"version" : "6.26.2"
}
},
{
Expand Down Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImage",
"state" : {
"revision" : "fb50c1d20f24db5322b2f8f379de3618f75fe08e",
"version" : "5.15.5"
"revision" : "3289629ef6cbf1ad8c3d1dccf0cf09ac97547cd6",
"version" : "5.15.7"
}
},
{
Expand All @@ -77,8 +77,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ivanvorobei/SPIndicator",
"state" : {
"revision" : "43600857729d9efff046dc6673e6f94e095882c7",
"version" : "1.6.4"
"revision" : "e8a045f91757b32bb29c6feff1644ef79c8daedf",
"version" : "1.6.5"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions Kimis/Extension/Generic/CGPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Lakr Aream on 2023/1/18.
//

import CoreGraphics
import Foundation

extension CGPoint: Hashable {
Expand Down
1 change: 1 addition & 0 deletions Kimis/Extension/Generic/CGRect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Lakr Aream on 2022/11/24.
//

import CoreGraphics
import Foundation

extension CGRect: Hashable {
Expand Down
1 change: 1 addition & 0 deletions Kimis/Extension/Generic/CGSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Lakr Aream on 2023/1/2.
//

import CoreGraphics
import Foundation

extension CGSize: Hashable {
Expand Down
20 changes: 20 additions & 0 deletions Kimis/KimisDebug.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.personal-information.photos-library</key>
<true/>
</dict>
</plist>

0 comments on commit d4a5667

Please sign in to comment.