mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Fix: Delay local network permission prompt to introduction
This commit is contained in:
1 parent
1bd15acaef
commit
8a9bb0bdfe
5 files changed
+46
-23
No files matched your search
@@ -1332,8 +1332,8 @@
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
SHARED_BUILD = 98;
|
||||
SHARED_VERSION = 2.9.1;
|
||||
SHARED_BUILD = 99;
|
||||
SHARED_VERSION = 2.10;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -1395,8 +1395,8 @@
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
SHARED_BUILD = 98;
|
||||
SHARED_VERSION = 2.9.1;
|
||||
SHARED_BUILD = 99;
|
||||
SHARED_VERSION = 2.10;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
||||
+20
-14
@@ -102,24 +102,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
}
|
||||
|
||||
BezelNotification.show(messageText: "ReadyToReceive".localized(), icon: .receiveIcon)
|
||||
|
||||
// only start receiving immediately for existing user, for new users we want to delay the permission prompt
|
||||
startReceiving()
|
||||
}
|
||||
|
||||
UNUserNotificationCenter.current().delegate = self
|
||||
|
||||
receiveModel = ReceiveModel(controlPlusScreen: { shouldOpen in
|
||||
if shouldOpen {
|
||||
self.openPlusScreen()
|
||||
}
|
||||
else {
|
||||
if let window = self.plusWindow {
|
||||
log("[AppDelegate] Closing plus screen because of error")
|
||||
window.close()
|
||||
self.plusWindow = nil
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
NearbyConnectionManager.shared.connectionUpdateCallback = { isConnected in
|
||||
if isConnected {
|
||||
self.statusItem?.button?.image = NSImage(named: "MenuBarIcon")
|
||||
@@ -139,6 +128,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
}
|
||||
|
||||
|
||||
func startReceiving() {
|
||||
receiveModel = ReceiveModel(controlPlusScreen: { shouldOpen in
|
||||
if shouldOpen {
|
||||
self.openPlusScreen()
|
||||
}
|
||||
else {
|
||||
if let window = self.plusWindow {
|
||||
log("[AppDelegate] Closing plus screen because of error")
|
||||
window.close()
|
||||
self.plusWindow = nil
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
func windowWillClose(_ notification: Notification) {
|
||||
if let window = notification.object as? NSWindow, window == welcomeWindow {
|
||||
log("Welcome window closed")
|
||||
@@ -221,6 +226,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
|
||||
let welcomeView = WelcomeScreen(
|
||||
openIntroduction: openIntroduction,
|
||||
startReceiving: startReceiving,
|
||||
openPlusScreen: openPlusScreen,
|
||||
openAppAdvertisementView: { self.openSheetView(type: .downloadAndroidApp) },
|
||||
openCableTransmissionView: { self.openSheetView(type: .downloadCableConnectionApp) },
|
||||
|
||||
@@ -16,6 +16,7 @@ struct IntroductionSplashView: View {
|
||||
@State private var pollingPage: IntroductionPage? = nil
|
||||
@State private var skipAction: IntroductionPage.SkipAction? = nil
|
||||
|
||||
let startReceiving: (() -> Void)
|
||||
let onFinish: (() -> Void)
|
||||
|
||||
var body: some View {
|
||||
@@ -177,8 +178,22 @@ struct IntroductionSplashView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func triggerLocalNetworkPermission() {
|
||||
self.startReceiving()
|
||||
|
||||
// just to be sure it is triggered
|
||||
runAfter(seconds: 1) {
|
||||
DeviceToDeviceHeuristicScanner.shared.scan(completion: { _ in })
|
||||
}
|
||||
}
|
||||
|
||||
private func advance() {
|
||||
|
||||
if currentPage == .localNetworkAccess {
|
||||
triggerLocalNetworkPermission()
|
||||
}
|
||||
|
||||
if let nextPage = currentPage.presentNextPage() {
|
||||
currentPage = nextPage
|
||||
} else {
|
||||
@@ -262,7 +277,6 @@ enum IntroductionPage: CaseIterable {
|
||||
case .noWifi:
|
||||
return .localNetworkAccess
|
||||
case .localNetworkAccess:
|
||||
DeviceToDeviceHeuristicScanner.shared.scan(completion: { _ in })
|
||||
return .enableShareExtension
|
||||
case .enableShareExtension:
|
||||
return .finished
|
||||
@@ -325,6 +339,6 @@ enum IntroductionPage: CaseIterable {
|
||||
|
||||
|
||||
#Preview {
|
||||
IntroductionSplashView{}
|
||||
IntroductionSplashView(startReceiving: {}){}
|
||||
.frame(width: 600, height: 500)
|
||||
}
|
||||
@@ -99,5 +99,5 @@ struct LargeAppIconView<Content: View>: View {
|
||||
|
||||
|
||||
#Preview {
|
||||
WelcomeScreen(openIntroduction: false, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {})
|
||||
WelcomeScreen(openIntroduction: false, startReceiving: {}, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {})
|
||||
}
|
||||
@@ -12,12 +12,14 @@ struct WelcomeScreen: View {
|
||||
|
||||
internal init(
|
||||
openIntroduction: Bool,
|
||||
startReceiving: @escaping () -> Void,
|
||||
openPlusScreen: @escaping () -> Void,
|
||||
openAppAdvertisementView: @escaping () -> Void,
|
||||
openCableTransmissionView: @escaping () -> Void,
|
||||
checkForNetworkIssues: @escaping () -> Void
|
||||
) {
|
||||
self._openedIntroduction = State(initialValue: openIntroduction)
|
||||
self.startReceiving = startReceiving
|
||||
self.openPlusScreen = openPlusScreen
|
||||
self.openAppAdvertisementView = openAppAdvertisementView
|
||||
self.openCableTransmissionView = openCableTransmissionView
|
||||
@@ -28,6 +30,7 @@ struct WelcomeScreen: View {
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
let openPlusScreen: () -> Void
|
||||
let startReceiving: () -> Void
|
||||
let openAppAdvertisementView: () -> Void
|
||||
let openCableTransmissionView: () -> Void
|
||||
let checkForNetworkIssues: () -> Void
|
||||
@@ -45,7 +48,7 @@ struct WelcomeScreen: View {
|
||||
.resizable()
|
||||
.ignoresSafeArea(.all)
|
||||
|
||||
IntroductionSplashView {
|
||||
IntroductionSplashView(startReceiving: startReceiving) {
|
||||
openedIntroduction = false
|
||||
}
|
||||
.background(Color(NSColor.windowBackgroundColor))
|
||||
@@ -239,5 +242,5 @@ enum Tabs: CaseIterable {
|
||||
|
||||
|
||||
#Preview {
|
||||
WelcomeScreen(openIntroduction: true, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {})
|
||||
WelcomeScreen(openIntroduction: true, startReceiving: {}, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {})
|
||||
}
|
||||
Reference in new issue
Block a user