Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions Nio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
4BFEFD86246F414D00CCF4A0 /* NioShareExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 4BFEFD7C246F414D00CCF4A0 /* NioShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
4BFEFD8C246F458000CCF4A0 /* GetURL.js in Resources */ = {isa = PBXBuildFile; fileRef = 4BFEFD8B246F458000CCF4A0 /* GetURL.js */; };
4BFEFD92246F686000CCF4A0 /* ShareContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BFEFD91246F686000CCF4A0 /* ShareContentView.swift */; };
9525D2CF26763DCB004055B6 /* MXSession+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525D2CD26763D74004055B6 /* MXSession+Async.swift */; };
9525D2D026763DCB004055B6 /* MXSession+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525D2CD26763D74004055B6 /* MXSession+Async.swift */; };
9525D2D126763DD0004055B6 /* MXRestClient+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525D2CB26763D06004055B6 /* MXRestClient+Async.swift */; };
9525D2D226763DD0004055B6 /* MXRestClient+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525D2CB26763D06004055B6 /* MXRestClient+Async.swift */; };
9525D2D326763DD0004055B6 /* MXAutoDiscovery+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525D2C726763CD4004055B6 /* MXAutoDiscovery+Async.swift */; };
9525D2D426763DD0004055B6 /* MXAutoDiscovery+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525D2C726763CD4004055B6 /* MXAutoDiscovery+Async.swift */; };
9525D2D526763DD0004055B6 /* MXRoom+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525D2C826763CD4004055B6 /* MXRoom+Async.swift */; };
9525D2D626763DD0004055B6 /* MXRoom+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525D2C826763CD4004055B6 /* MXRoom+Async.swift */; };
A51BF8CE254C2FE5000FB0A4 /* NioApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51BF8CD254C2FE5000FB0A4 /* NioApp.swift */; };
A51F762C25D6E9950061B4A4 /* MessageTextViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51F762B25D6E9950061B4A4 /* MessageTextViewWrapper.swift */; };
A58352A625A667AB00533363 /* MatrixSDK in Frameworks */ = {isa = PBXBuildFile; productRef = A58352A525A667AB00533363 /* MatrixSDK */; };
Expand Down Expand Up @@ -360,6 +368,10 @@
4BFEFD8F246F5EE000CCF4A0 /* NioShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NioShareExtension.entitlements; sourceTree = "<group>"; };
4BFEFD90246F5EF500CCF4A0 /* Nio.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Nio.entitlements; sourceTree = "<group>"; };
4BFEFD91246F686000CCF4A0 /* ShareContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareContentView.swift; sourceTree = "<group>"; };
9525D2C726763CD4004055B6 /* MXAutoDiscovery+Async.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MXAutoDiscovery+Async.swift"; sourceTree = "<group>"; };
9525D2C826763CD4004055B6 /* MXRoom+Async.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MXRoom+Async.swift"; sourceTree = "<group>"; };
9525D2CB26763D06004055B6 /* MXRestClient+Async.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MXRestClient+Async.swift"; sourceTree = "<group>"; };
9525D2CD26763D74004055B6 /* MXSession+Async.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MXSession+Async.swift"; sourceTree = "<group>"; };
A51BF8CD254C2FE5000FB0A4 /* NioApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NioApp.swift; sourceTree = "<group>"; };
A51F762B25D6E9950061B4A4 /* MessageTextViewWrapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageTextViewWrapper.swift; sourceTree = "<group>"; };
CAAF5BF72478696F006FDC33 /* UITextViewWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITextViewWrapper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -803,6 +815,10 @@
CAD6816E246B1BB0001878EB /* Extensions */ = {
isa = PBXGroup;
children = (
9525D2CB26763D06004055B6 /* MXRestClient+Async.swift */,
9525D2C726763CD4004055B6 /* MXAutoDiscovery+Async.swift */,
9525D2C826763CD4004055B6 /* MXRoom+Async.swift */,
9525D2CD26763D74004055B6 /* MXSession+Async.swift */,
39BA0722240B3C9A00FD28C6 /* MXCredentials+Keychain.swift */,
392389882386FD3900B2E1DF /* MXClient+Publisher.swift */,
3923898C238859D100B2E1DF /* MX+Identifiable.swift */,
Expand Down Expand Up @@ -1354,17 +1370,21 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9525D2D226763DD0004055B6 /* MXRestClient+Async.swift in Sources */,
E8B4725A25F26D5A00ACEFCB /* MX+Identifiable.swift in Sources */,
E8B4725B25F26D5A00ACEFCB /* Reaction.swift in Sources */,
9525D2CF26763DCB004055B6 /* MXSession+Async.swift in Sources */,
E8B4725525F26D5A00ACEFCB /* MXClient+Publisher.swift in Sources */,
E897AA3425F2716F00D11427 /* UXKit.swift in Sources */,
9525D2D626763DD0004055B6 /* MXRoom+Async.swift in Sources */,
E8B4725625F26D5A00ACEFCB /* ReactionEvent.swift in Sources */,
E8B4725925F26D5A00ACEFCB /* NIORoomSummary.swift in Sources */,
E8B4725725F26D5A00ACEFCB /* EditEvent.swift in Sources */,
E8B4726125F26D5A00ACEFCB /* AccountStore.swift in Sources */,
E8B4725825F26D5A00ACEFCB /* CustomEvent.swift in Sources */,
E8B4725F25F26D5A00ACEFCB /* Configuration.swift in Sources */,
E8B4725D25F26D5A00ACEFCB /* EventCollection.swift in Sources */,
9525D2D426763DD0004055B6 /* MXAutoDiscovery+Async.swift in Sources */,
E8B4725E25F26D5A00ACEFCB /* MXEvent+Extensions.swift in Sources */,
E8B4725425F26D5A00ACEFCB /* MXCredentials+Keychain.swift in Sources */,
E8B4726025F26D5A00ACEFCB /* UserDefaults.swift in Sources */,
Expand Down Expand Up @@ -1437,17 +1457,21 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9525D2D126763DD0004055B6 /* MXRestClient+Async.swift in Sources */,
E897AA2025F2707C00D11427 /* NIORoomSummary.swift in Sources */,
E897AA2525F2707C00D11427 /* ReactionEvent.swift in Sources */,
9525D2D026763DCB004055B6 /* MXSession+Async.swift in Sources */,
E897AA2225F2707C00D11427 /* AccountStore.swift in Sources */,
E897AA3525F2716F00D11427 /* UXKit.swift in Sources */,
9525D2D526763DD0004055B6 /* MXRoom+Async.swift in Sources */,
E897AA1E25F2707C00D11427 /* MXClient+Publisher.swift in Sources */,
E897AA1B25F2707C00D11427 /* Configuration.swift in Sources */,
E897AA1C25F2707C00D11427 /* CustomEvent.swift in Sources */,
E897AA2325F2707C00D11427 /* Reaction.swift in Sources */,
E897AA1925F2707C00D11427 /* EditEvent.swift in Sources */,
E897AA1F25F2707C00D11427 /* MX+Identifiable.swift in Sources */,
E897AA1D25F2707C00D11427 /* MXCredentials+Keychain.swift in Sources */,
9525D2D326763DD0004055B6 /* MXAutoDiscovery+Async.swift in Sources */,
E897AA2425F2707C00D11427 /* MXEvent+Extensions.swift in Sources */,
E897AA2125F2707C00D11427 /* EventCollection.swift in Sources */,
E897AA2625F2707C00D11427 /* UserDefaults.swift in Sources */,
Expand Down Expand Up @@ -1712,6 +1736,7 @@
DEVELOPMENT_ASSET_PATHS = "\"Nio/Preview Content\"";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Nio/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -1736,6 +1761,7 @@
DEVELOPMENT_TEAM = HU85FER47E;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Nio/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -1756,7 +1782,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 33;
INFOPLIST_FILE = NioShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -1778,7 +1804,7 @@
CURRENT_PROJECT_VERSION = 33;
DEVELOPMENT_TEAM = HU85FER47E;
INFOPLIST_FILE = NioShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -1843,7 +1869,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4GXF3JAMM4;
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_MODULE_NAME = NioKit;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1858,7 +1884,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4GXF3JAMM4;
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_MODULE_NAME = NioKit;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1884,7 +1910,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 12.0;
PRODUCT_BUNDLE_IDENTIFIER = "$(MAC_PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand All @@ -1908,7 +1934,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 12.0;
PRODUCT_BUNDLE_IDENTIFIER = chat.nio.mio;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand All @@ -1922,7 +1948,8 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4GXF3JAMM4;
EXECUTABLE_PREFIX = lib;
MACOSX_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MACOSX_DEPLOYMENT_TARGET = 12.0;
PRODUCT_MODULE_NAME = NioKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand All @@ -1936,7 +1963,8 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4GXF3JAMM4;
EXECUTABLE_PREFIX = lib;
MACOSX_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MACOSX_DEPLOYMENT_TARGET = 12.0;
PRODUCT_MODULE_NAME = NioKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Nio/Authentication/LoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ struct LoadingView: View {

Spacer()

Button(action: self.store.logout) {
Button(action: {
asyncDetached {
await self.store.logout()
}
}) {
Text(verbatim: L10n.Loading.cancel).font(.callout)
}
.padding()
Expand Down
4 changes: 3 additions & 1 deletion Nio/Authentication/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ struct LoginContainerView: View {
return
}

store.login(username: username, password: password, homeserver: homeserverURL)
async {
await store.login(username: username, password: password, homeserver: homeserverURL)
}
}

private func guessHomeserverURL() {
Expand Down
17 changes: 14 additions & 3 deletions Nio/NewConversation/NewConversationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ private struct NewConversationView: View {
@Binding var createdRoomId: ObjectIdentifier?
@State private var errorMessage: String?

@MainActor
private var usersFooter: some View {
Text("\(L10n.NewConversation.forExample) \(store?.session?.myUserId ?? "@username:server.org")")
}

@MainActor
private var form: some View {
Form {
Section(footer: usersFooter) {
Expand Down Expand Up @@ -65,7 +67,12 @@ private struct NewConversationView: View {
Section {
HStack {
#if !os(macOS)
Button(action: createRoom) {
// Seems to be a bug in Xcode, currently needs to be asnyc, to be able to await actor
Button(action: {
async {
createRoom
}
}) {
Text(verbatim: L10n.NewConversation.createRoom)
}
.disabled(users.contains("") || (roomName.isEmpty && users.count > 1))
Expand Down Expand Up @@ -94,7 +101,11 @@ private struct NewConversationView: View {
}
}
ToolbarItem(placement: .confirmationAction) {
Button(action: createRoom) {
Button(action: {
async {
await createRoom
}
}) {
Text(verbatim: L10n.NewConversation.createRoom)
}
.disabled(users.contains("") || (roomName.isEmpty && users.count > 1))
Expand Down Expand Up @@ -140,7 +151,7 @@ private struct NewConversationView: View {
}
}

private func createRoom() {
@MainActor private func createRoom() {
isWaiting = true

let parameters = MXRoomCreationParameters()
Expand Down
14 changes: 11 additions & 3 deletions Nio/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ struct SettingsContainerView: View {
@EnvironmentObject var store: AccountStore

var body: some View {
#if os(macOS)
MacSettingsView(logoutAction: self.store.logout)
#if os(macOS)
MacSettingsView(logoutAction: {
async {
await self.store.logout()
}
})
#else
SettingsView(logoutAction: self.store.logout)
SettingsView(logoutAction: {
async {
await self.store.logout()
}
})
#endif
}
}
Expand Down
17 changes: 17 additions & 0 deletions NioKit/Extensions/MXAutoDiscovery+Async.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// MXAutoDiscovery+Async.swift
// Masui
//
// Created by Finn Behrens on 11.06.21.
//

import Foundation
import MatrixSDK

extension MXAutoDiscovery {
public func findClientConfig() async throws -> MXDiscoveredClientConfig {
return try await withCheckedThrowingContinuation {continuation in
self.findClientConfig({ continuation.resume(returning: $0)}, failure: {continuation.resume(throwing: $0)})
}
}
}
32 changes: 32 additions & 0 deletions NioKit/Extensions/MXRestClient+Async.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// MXRestClient+async.swift
// Masui
//
// Created by Finn Behrens on 11.06.21.
//

import Foundation
import MatrixSDK

extension MXRestClient {
func login(type loginType: MatrixSDK.MXLoginFlowType = .password, username: String, password: String) async throws -> MXCredentials {
return try await withCheckedThrowingContinuation {continuation in
self.login(type: loginType, username: username, password: password, completion: {resp in
switch resp {
case .success(let v):
continuation.resume(returning: v)
case .failure(let e):
continuation.resume(throwing: e)
@unknown default:
continuation.resume(throwing: NioUnknownContinuationSwitchError(value: resp))
}
})
}
}

func wellKnown() async throws -> MXWellKnown {
return try await withCheckedThrowingContinuation {continuation in
self.wellKnow({continuation.resume(returning: $0!)}, failure: {continuation.resume(throwing: $0!)})
}
}
}
26 changes: 26 additions & 0 deletions NioKit/Extensions/MXRoom+Async.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// MXRoom+Asnyc.swift
// Masui
//
// Created by Finn Behrens on 11.06.21.
//

import Foundation
import MatrixSDK

extension MXRoom {
func members() async throws -> MXRoomMembers? {
return try await withCheckedThrowingContinuation {continuation in
self.members(completion: {resp in
switch resp {
case .success(let v):
continuation.resume(returning: v)
case .failure(let e):
continuation.resume(throwing: e)
@unknown default:
continuation.resume(throwing: NioUnknownContinuationSwitchError(value: resp))
}
})
}
}
}
Loading