Browse Source

Merge pull request #1746 from deltachat/webxdc_connectivity_permission

webxdc internet_access flag
cyBerta 2 years ago
parent
commit
be8a2b5bb9
1 changed files with 7 additions and 1 deletions
  1. 7 1
      deltachat-ios/Controller/WebxdcViewController.swift

+ 7 - 1
deltachat-ios/Controller/WebxdcViewController.swift

@@ -15,6 +15,7 @@ class WebxdcViewController: WebViewViewController {
     var webxdcUpdateObserver: NSObjectProtocol?
     var webxdcUpdateObserver: NSObjectProtocol?
     var webxdcName: String = ""
     var webxdcName: String = ""
     var sourceCodeUrl: String?
     var sourceCodeUrl: String?
+    private var allowInternet: Bool = false
 
 
     private var shortcutManager: ShortcutManager?
     private var shortcutManager: ShortcutManager?
 
 
@@ -170,6 +171,7 @@ class WebxdcViewController: WebViewViewController {
         let document = dict["document"] as? String ?? ""
         let document = dict["document"] as? String ?? ""
         webxdcName = dict["name"] as? String ?? "ErrName" // name should not be empty
         webxdcName = dict["name"] as? String ?? "ErrName" // name should not be empty
         let chatName = dcContext.getChat(chatId: msg.chatId).name
         let chatName = dcContext.getChat(chatId: msg.chatId).name
+        self.allowInternet = dict["internet_access"] as? Bool ?? false
 
 
         self.title = document.isEmpty ? "\(webxdcName) – \(chatName)" : "\(document) – \(chatName)"
         self.title = document.isEmpty ? "\(webxdcName) – \(chatName)" : "\(document) – \(chatName)"
         navigationItem.rightBarButtonItem = moreButton
         navigationItem.rightBarButtonItem = moreButton
@@ -234,7 +236,11 @@ class WebxdcViewController: WebViewViewController {
     
     
     override func viewWillAppear(_ animated: Bool) {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         super.viewWillAppear(animated)
-        loadRestrictedHtml()
+        if allowInternet {
+            loadHtml()
+        } else {
+            loadRestrictedHtml()
+        }
     }
     }
 
 
     override func viewDidDisappear(_ animated: Bool) {
     override func viewDidDisappear(_ animated: Bool) {