From 2cd3c33b89ed5662579281943e13ffcefb4ac265 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 7 Oct 2022 07:31:17 -0700 Subject: [PATCH] Add a little logging for tile import process --- Meshtastic/MeshtasticApp.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Meshtastic/MeshtasticApp.swift b/Meshtastic/MeshtasticApp.swift index 227f70c4..5647e05b 100644 --- a/Meshtastic/MeshtasticApp.swift +++ b/Meshtastic/MeshtasticApp.swift @@ -40,13 +40,17 @@ struct MeshtasticAppleApp: App { } .onOpenURL(perform: { (url) in - print("QR Code URL received from the Camera \(url)") + print("Some sort of URL was received \(url)") channelUrl = url - print("User wants to open URL: \(channelUrl?.absoluteString ?? "No QR Code Link")") + if url.absoluteString.lowercased().contains("https://meshtastic.org/e/#") { saveQR = true + print("User wants to open a Channel Settings URL: \(channelUrl?.absoluteString ?? "No QR Code Link")") + } else { + print("User wants to import a MBTILES offline map file: \(channelUrl?.absoluteString ?? "No Tiles link")") } + //we are expecting a .mbtiles map file that contains raster data //save it to the documents directory, and name it offline_map.mbtiles @@ -60,7 +64,11 @@ struct MeshtasticAppleApp: App { try? fileManager.removeItem(atPath: destination.path) } - try? fileManager.copyItem(at: url, to: destination) + do { + try fileManager.copyItem(at: url, to: destination) + } catch { + print("Copy MB Tile file failed. Error: \(error)") + } if (fileManager.fileExists(atPath: destination.path)) { print("ℹ️ Saved the map file")