@poolse/react-native-calls 0.7.0 → 0.7.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.
@@ -65,6 +65,7 @@ object MessageNotifications {
65
65
  val state = load(context, conversationId) ?: Conversation(conversationId)
66
66
  state.title = data["conversation_name"]?.ifBlank { null } ?: state.title
67
67
  state.group = data["group"] == "1"
68
+ state.hidden = data["private"] == "1"
68
69
  data["reply_grant"]?.ifBlank { null }?.let { state.grant = it }
69
70
  val messageId = data["message_id"]
70
71
  if (messageId == null || state.lines.none { it.id == messageId }) {
@@ -124,7 +125,6 @@ object MessageNotifications {
124
125
  val id = notificationId(state.id)
125
126
  val builder = NotificationCompat.Builder(context, CHANNEL_ID)
126
127
  .setSmallIcon(smallIcon)
127
- .setStyle(style)
128
128
  .setCategory(NotificationCompat.CATEGORY_MESSAGE)
129
129
  .setPriority(NotificationCompat.PRIORITY_HIGH)
130
130
  .setGroup(GROUP_KEY)
@@ -132,6 +132,16 @@ object MessageNotifications {
132
132
  .setOnlyAlertOnce(!alert)
133
133
  .setWhen(state.lines.lastOrNull()?.at ?: System.currentTimeMillis())
134
134
  .setNumber(state.lines.count { !it.self })
135
+ if (state.hidden) {
136
+ // The tenant hides previews: nothing about who or what — the app's
137
+ // name and a count. The server never sent the text anyway.
138
+ val unread = state.lines.count { !it.self }
139
+ builder
140
+ .setContentTitle(context.applicationInfo.loadLabel(context.packageManager))
141
+ .setContentText(if (unread <= 1) "New message" else "$unread new messages")
142
+ } else {
143
+ builder.setStyle(style)
144
+ }
135
145
  openIntent(context, state.id, id)?.let(builder::setContentIntent)
136
146
 
137
147
  if (state.grant != null) {
@@ -237,6 +247,7 @@ object MessageNotifications {
237
247
  var group: Boolean = false,
238
248
  var grant: String? = null,
239
249
  val lines: MutableList<Line> = mutableListOf(),
250
+ var hidden: Boolean = false,
240
251
  )
241
252
 
242
253
  private fun prefs(context: Context) =
@@ -254,6 +265,7 @@ object MessageNotifications {
254
265
  title = o.optString("title").ifBlank { null },
255
266
  group = o.optBoolean("group"),
256
267
  grant = o.optString("grant").ifBlank { null },
268
+ hidden = o.optBoolean("hidden"),
257
269
  lines = MutableList(lines.length()) { i ->
258
270
  val l = lines.getJSONObject(i)
259
271
  Line(
@@ -286,6 +298,7 @@ object MessageNotifications {
286
298
  .put("title", c.title ?: "")
287
299
  .put("group", c.group)
288
300
  .put("grant", c.grant ?: "")
301
+ .put("hidden", c.hidden)
289
302
  .put("lines", lines)
290
303
  prefs(context).edit().putString(key(c.id), o.toString()).apply()
291
304
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poolse/react-native-calls",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Native call core for poolse — Kotlin/Swift calling engine with a thin React Native bridge. Ring, answer and carry audio with the app killed and the phone locked.",
5
5
  "license": "MIT",
6
6
  "type": "module",