implement js changes
This commit is contained in:
+6
-4
@@ -41,9 +41,9 @@ public class ExpoBackgroundNotificationHandlerModule: Module {
|
||||
SharedPrefs.shared.setValue(BadgeType.generic.toKeyName(), 0)
|
||||
}
|
||||
|
||||
AsyncFunction("incrementMessagesCountAsync") { (convoId: String) in
|
||||
AsyncFunction("maybeIncrementMessagesCountAsync") { (convoId: String) in
|
||||
guard !SharedPrefs.shared.setContains(INCREMENTED_FOR_KEY, convoId) else {
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
var count = SharedPrefs.shared.getNumber(BadgeType.messages.toKeyName()) ?? 0
|
||||
@@ -51,11 +51,12 @@ public class ExpoBackgroundNotificationHandlerModule: Module {
|
||||
|
||||
SharedPrefs.shared.addToSet(INCREMENTED_FOR_KEY, convoId)
|
||||
SharedPrefs.shared.setValue(BadgeType.messages.toKeyName(), count)
|
||||
return true
|
||||
}
|
||||
|
||||
AsyncFunction("decrementMessagesCountAsync") { (convoId: String) in
|
||||
AsyncFunction("maybeDecrementMessagesCountAsync") { (convoId: String) in
|
||||
guard SharedPrefs.shared.setContains(INCREMENTED_FOR_KEY, convoId) else {
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
var count = SharedPrefs.shared.getNumber(BadgeType.messages.toKeyName()) ?? 0
|
||||
@@ -63,6 +64,7 @@ public class ExpoBackgroundNotificationHandlerModule: Module {
|
||||
|
||||
SharedPrefs.shared.removeFromSet(INCREMENTED_FOR_KEY, convoId)
|
||||
SharedPrefs.shared.setValue(BadgeType.messages.toKeyName(), count)
|
||||
return true
|
||||
}
|
||||
|
||||
AsyncFunction("getPrefsAsync") {
|
||||
|
||||
@@ -4,22 +4,20 @@ import {BackgroundNotificationHandlerPreferences} from './ExpoBackgroundNotifica
|
||||
|
||||
const NativeModule = requireNativeModule('ExpoBackgroundNotificationHandler')
|
||||
|
||||
export function resetGenericCountAsync(count: number): Promise<void> {
|
||||
NativeModule.resetGenericCountAsync(count)
|
||||
export function resetGenericCountAsync(): Promise<void> {
|
||||
NativeModule.resetGenericCountAsync()
|
||||
}
|
||||
|
||||
export function incrementMessagesCountAsync(
|
||||
count: number,
|
||||
export function maybeIncrementMessagesCountAsync(
|
||||
convoId: string,
|
||||
): Promise<void> {
|
||||
NativeModule.incrementMessagesCountAsync(count, convoId)
|
||||
): Promise<boolean> {
|
||||
NativeModule.incrementMessagesCountAsync(convoId)
|
||||
}
|
||||
|
||||
export function decrementMessagesCountAsync(
|
||||
count: number,
|
||||
export function maybeDecrementMessagesCountAsync(
|
||||
convoId: string,
|
||||
): Promise<void> {
|
||||
NativeModule.decrementMessagesCountAsync(count, convoId)
|
||||
): Promise<boolean> {
|
||||
NativeModule.decrementMessagesCountAsync(convoId)
|
||||
}
|
||||
|
||||
export function getPrefsAsync(): Promise<BackgroundNotificationHandlerPreferences> {
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
import {NotImplementedError} from './NotImplemented'
|
||||
import {BackgroundNotificationHandlerPreferences} from './types'
|
||||
|
||||
export function resetGenericCountAsync(count: number): Promise<void> {
|
||||
throw new NotImplementedError({count})
|
||||
export function resetGenericCountAsync(): Promise<void> {
|
||||
throw new NotImplementedError()
|
||||
}
|
||||
|
||||
export function incrementMessagesCountAsync(
|
||||
count: number,
|
||||
export function maybeIncrementMessagesCountAsync(
|
||||
convoId: string,
|
||||
): Promise<void> {
|
||||
throw new NotImplementedError({count, convoId})
|
||||
): Promise<boolean> {
|
||||
throw new NotImplementedError({convoId})
|
||||
}
|
||||
|
||||
export function decrementMessagesCountAsync(
|
||||
count: number,
|
||||
export function maybeDecrementMessagesCountAsync(
|
||||
convoId: string,
|
||||
): Promise<void> {
|
||||
throw new NotImplementedError({count, convoId})
|
||||
): Promise<boolean> {
|
||||
throw new NotImplementedError({convoId})
|
||||
}
|
||||
|
||||
export function getPrefsAsync(): Promise<BackgroundNotificationHandlerPreferences | null> {
|
||||
|
||||
Reference in New Issue
Block a user