Skip to content

Commit

Permalink
core emits DC_EVENT_WEBXDC_STATUS_UPDATE now, no need to listen to sp…
Browse files Browse the repository at this point in the history
…ecial location event
  • Loading branch information
r10s committed Apr 14, 2024
1 parent d66b04b commit 37da6fa
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 35 deletions.
10 changes: 0 additions & 10 deletions DcCore/DcCore/DC/events.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public let eventEphemeralTimerModified = Notification.Name(rawValue: "eventEphe
public let eventMsgsNoticed = Notification.Name(rawValue: "eventMsgsNoticed")
public let eventConnectivityChanged = Notification.Name(rawValue: "eventConnectivityChanged")
public let eventWebxdcStatusUpdate = Notification.Name(rawValue: "eventWebxdcStatusUpdate")
public let eventLocationChanged = Notification.Name(rawValue: "eventLocationChanged")

public class DcEventHandler {
let dcAccounts: DcAccounts
Expand Down Expand Up @@ -175,15 +174,6 @@ public class DcEventHandler {
])
}

case DC_EVENT_LOCATION_CHANGED:
if accountId != dcAccounts.getSelected().id {
return
}
logger.info("📡[\(accountId)] location changed for contact \(data1)")
DispatchQueue.main.async {
NotificationCenter.default.post(name: eventLocationChanged, object: nil)
}

default:
break
}
Expand Down
24 changes: 0 additions & 24 deletions deltachat-ios/Controller/MapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import WebKit
import DcCore

class MapViewController: WebxdcViewController {
private var locationChangedObserver: NSObjectProtocol?
private let isGlobalMap: Bool

init(dcContext: DcContext, chatId: Int) {
Expand All @@ -27,31 +26,8 @@ class MapViewController: WebxdcViewController {
navigationItem.rightBarButtonItem = nil
}

override func willMove(toParent parent: UIViewController?) {
super.willMove(toParent: parent)
if parent == nil {
removeObservers()
} else {
addObservers()
}
}

override func refreshWebxdcInfo() {
super.refreshWebxdcInfo()
title = String.localized(isGlobalMap ? "menu_show_global_map" : "locations")
}

// MARK: - setup

private func addObservers() {
locationChangedObserver = NotificationCenter.default.addObserver(forName: eventLocationChanged, object: nil, queue: nil) { [weak self]_ in
self?.updateWebxdc()
}
}

private func removeObservers() {
if let locationChangedObserver = self.locationChangedObserver {
NotificationCenter.default.removeObserver(locationChangedObserver)
}
}
}
2 changes: 1 addition & 1 deletion deltachat-ios/Controller/WebxdcViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class WebxdcViewController: WebViewViewController {
}
}

func updateWebxdc() {
private func updateWebxdc() {
webView.evaluateJavaScript("window.__webxdcUpdate()", completionHandler: nil)
}

Expand Down

0 comments on commit 37da6fa

Please sign in to comment.