expo-clipboard 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,13 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 4.0.1 — 2022-10-30
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fixed clipboard listener is called twice on Android. ([#19723](https://github.com/expo/expo/pull/19723) by [@lukmccall](https://github.com/lukmccall))
18
+ - Fixed clipboard listener can crash the application during initialization on Android. ([#19723](https://github.com/expo/expo/pull/19723) by [@lukmccall](https://github.com/lukmccall))
19
+
13
20
  ## 4.0.0 — 2022-10-25
14
21
 
15
22
  ### 🛠 Breaking changes
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '4.0.0'
6
+ version = '4.0.1'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -74,7 +74,7 @@ android {
74
74
  minSdkVersion safeExtGet("minSdkVersion", 21)
75
75
  targetSdkVersion safeExtGet("targetSdkVersion", 31)
76
76
  versionCode 3
77
- versionName '4.0.0'
77
+ versionName '4.0.1'
78
78
  }
79
79
  lintOptions {
80
80
  abortOnError false
@@ -147,19 +147,34 @@ class ClipboardModule : Module() {
147
147
 
148
148
  private inner class ClipboardEventEmitter {
149
149
  private var isListening = true
150
+ private var timestamp = -1L
151
+ fun resumeListening() {
152
+ isListening = true
153
+ }
150
154
 
151
- fun resumeListening() { isListening = true }
152
- fun pauseListening() { isListening = false }
155
+ fun pauseListening() {
156
+ isListening = false
157
+ }
153
158
 
154
159
  fun attachListener() = maybeClipboardManager?.addPrimaryClipChangedListener(listener).ifNull {
155
160
  Log.e(TAG, "'CLIPBOARD_SERVICE' unavailable. Events won't be received")
156
161
  }
162
+
157
163
  fun detachListener() = maybeClipboardManager?.removePrimaryClipChangedListener(listener)
158
164
 
159
165
  private val listener = ClipboardManager.OnPrimaryClipChangedListener {
166
+ if (!appContext.hasActiveReactInstance) {
167
+ return@OnPrimaryClipChangedListener
168
+ }
169
+
160
170
  maybeClipboardManager.takeIf { isListening }
161
171
  ?.primaryClipDescription
162
172
  ?.let { clip ->
173
+ if (timestamp == clip.timestamp) {
174
+ return@OnPrimaryClipChangedListener
175
+ }
176
+ timestamp = clip.timestamp
177
+
163
178
  this@ClipboardModule.sendEvent(
164
179
  CLIPBOARD_CHANGED_EVENT_NAME,
165
180
  bundleOf(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-clipboard",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "ExpoClipboard standalone module",
5
5
  "main": "build/Clipboard.js",
6
6
  "types": "build/Clipboard.d.ts",
@@ -39,5 +39,5 @@
39
39
  "jest": {
40
40
  "preset": "expo-module-scripts/universal"
41
41
  },
42
- "gitHead": "eab2b09c735fb0fc2bf734a3f29a6593adba3838"
42
+ "gitHead": "779ad6af070d07a14f371e3106f02ddd1b093538"
43
43
  }