Skip to content

Commit

Permalink
feat: swift formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
hirbod committed Jun 22, 2023
1 parent 76bc587 commit 5ba578e
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions ios/VolumeManagerSilentListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,51 @@ import Mute

@objc(VolumeManagerSilentListener)
class SilentListener: RCTEventEmitter {
override static func requiresMainQueueSetup() -> Bool {
return true;
}

override func supportedEvents() -> [String]! {
return ["RNVMSilentEvent"]
}

var previousValue: Bool = false
var hasListeners: Bool = false
var initialValueReported: Bool = false

override init() {
super.init()

Mute.shared.checkInterval = 2.0
Mute.shared.alwaysNotify = true
Mute.shared.isPaused = true;
Mute.shared.notify = onNotify
}

@objc func setInterval(_ newInterval: NSNumber) {
Mute.shared.checkInterval = Double(newInterval);
}

func onNotify(_ newVal: Bool) {
if hasListeners {
if previousValue == newVal && self.initialValueReported {
return
}
let body = ["isMuted": newVal, "initialQuery": !self.initialValueReported]

self.initialValueReported = true;
previousValue = newVal
sendEvent(withName: "RNVMSilentEvent", body: body)
override static func requiresMainQueueSetup() -> Bool {
return true
}

override func supportedEvents() -> [String]! {
return ["RNVMSilentEvent"]
}

var previousValue: Bool = false
var hasListeners: Bool = false
var initialValueReported: Bool = false

override init() {
super.init()

Mute.shared.checkInterval = 2.0
Mute.shared.alwaysNotify = true
Mute.shared.isPaused = true
Mute.shared.notify = onNotify
}

@objc func setInterval(_ newInterval: NSNumber) {
Mute.shared.checkInterval = Double(newInterval)
}

func onNotify(_ newVal: Bool) {
if hasListeners {
if previousValue == newVal && self.initialValueReported {
return
}
}
let body = ["isMuted": newVal, "initialQuery": !self.initialValueReported]

override func startObserving() {
self.hasListeners = true
Mute.shared.isPaused = false;
self.initialValueReported = true
previousValue = newVal
sendEvent(withName: "RNVMSilentEvent", body: body)
}
}

override func stopObserving() {
self.hasListeners = false;
Mute.shared.isPaused = true;
}
override func startObserving() {
self.hasListeners = true
Mute.shared.isPaused = false
}

override func stopObserving() {
self.hasListeners = false
Mute.shared.isPaused = true
}
}

0 comments on commit 5ba578e

Please sign in to comment.