From 4a0017d491601e8774a202f72a3f1996bbdd4a86 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 13 Jun 2024 12:52:26 -0700 Subject: [PATCH] fix: group image url --- example/ios/Podfile.lock | 14 +++++++------- ios/Wrappers/GroupWrapper.swift | 3 ++- ios/XMTPModule.swift | 29 ++++++++++++++++++++++++++--- ios/XMTPReactNative.podspec | 2 +- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index a2f8a171..6304edf6 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -56,7 +56,7 @@ PODS: - hermes-engine/Pre-built (= 0.71.14) - hermes-engine/Pre-built (0.71.14) - libevent (2.1.12) - - LibXMTP (0.5.1-beta1) + - LibXMTP (0.5.1-beta2) - Logging (1.0.0) - MessagePacker (0.4.7) - MMKV (1.3.5): @@ -449,16 +449,16 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.11.6): + - XMTP (0.11.7): - Connect-Swift (= 0.12.0) - GzipSwift - - LibXMTP (= 0.5.1-beta1) + - LibXMTP (= 0.5.1-beta2) - web3.swift - XMTPReactNative (0.1.0): - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.11.6) + - XMTP (= 0.11.7) - Yoga (1.14.0) DEPENDENCIES: @@ -711,7 +711,7 @@ SPEC CHECKSUMS: GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - LibXMTP: f897dba3ea05dd5f8b9d098176cd9cb7c73ad505 + LibXMTP: 954acfb393be3b19bf44ea9009af558c00222450 Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26 MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02 MMKV: 506311d0494023c2f7e0b62cc1f31b7370fa3cfb @@ -763,8 +763,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: 5986c7bc1400b8b054569d4c7c6d2f673d992be1 - XMTPReactNative: ed4824399c26767008b8266992085461f0cece98 + XMTP: b8ab59997ee95106778f445992fa00adce6c2d71 + XMTPReactNative: fc0eae046a9a3e3031c6d3b9921e15a6d5b13e09 Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2 diff --git a/ios/Wrappers/GroupWrapper.swift b/ios/Wrappers/GroupWrapper.swift index f0dd86b0..dd98115d 100644 --- a/ios/Wrappers/GroupWrapper.swift +++ b/ios/Wrappers/GroupWrapper.swift @@ -27,7 +27,8 @@ struct GroupWrapper { "permissionLevel": permissionString, "creatorInboxId": try group.creatorInboxId(), "name": try group.groupName(), - "isActive": try group.isActive() + "isActive": try group.isActive(), + "imageUrlSquare": try group.groupImageUrlSquare(), ] } diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 509277ad..9032eefa 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -659,7 +659,7 @@ public class XMTPModule: Module { } } - AsyncFunction("createGroup") { (inboxId: String, peerAddresses: [String], permission: String) -> String in + AsyncFunction("createGroup") { (inboxId: String, peerAddresses: [String], permission: String, groupName: String, groupImageUrlSquare: String) -> String in guard let client = await clientsManager.getClient(key: inboxId) else { throw Error.noClient } @@ -672,7 +672,7 @@ public class XMTPModule: Module { } }() do { - let group = try await client.conversations.newGroup(with: peerAddresses, permissions: permissionLevel) + let group = try await client.conversations.newGroup(with: peerAddresses, permissions: permissionLevel, name: groupName, imageUrlSquare: groupImageUrlSquare) return try GroupWrapper.encode(group, client: client) } catch { print("ERRRO!: \(error.localizedDescription)") @@ -769,7 +769,6 @@ public class XMTPModule: Module { try await group.removeMembersByInboxId(inboxIds: inboxIds) } - AsyncFunction("groupName") { (inboxId: String, id: String) -> String in guard let client = await clientsManager.getClient(key: inboxId) else { throw Error.noClient @@ -794,6 +793,30 @@ public class XMTPModule: Module { try await group.updateGroupName(groupName: groupName) } + AsyncFunction("groupImageUrlSquare") { (inboxId: String, id: String) -> String in + guard let client = await clientsManager.getClient(key: inboxId) else { + throw Error.noClient + } + + guard let group = try await findGroup(inboxId: inboxId, id: id) else { + throw Error.conversationNotFound("no group found for \(id)") + } + + return try group.groupImageUrlSquare() + } + + AsyncFunction("updateGroupImageUrlSquare") { (inboxId: String, id: String, groupImageUrl: String) in + guard let client = await clientsManager.getClient(key: inboxId) else { + throw Error.noClient + } + + guard let group = try await findGroup(inboxId: inboxId, id: id) else { + throw Error.conversationNotFound("no group found for \(id)") + } + + try await group.updateGroupImageUrlSquare(imageUrlSquare: groupImageUrl) + } + AsyncFunction("isGroupActive") { (inboxId: String, id: String) -> Bool in guard let client = await clientsManager.getClient(key: inboxId) else { throw Error.noClient diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index 2f02bee6..0cf94430 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -26,5 +26,5 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency 'secp256k1.swift' s.dependency "MessagePacker" - s.dependency "XMTP", "= 0.11.6" + s.dependency "XMTP", "= 0.11.7" end