Skip to content

Commit 99cce41

Browse files
committed
chore: update compressImage interface
1 parent 65ccb6e commit 99cce41

File tree

7 files changed

+29
-24
lines changed

7 files changed

+29
-24
lines changed

.yarn/releases/yarn-1.19.0.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95215,7 +95215,7 @@ RequestSigner.prototype.sign = function() {
9521595215
this.request.headers.Authorization = this.authHeader()
9521695216
}
9521795217

95218-
this.request.path = this.formatPath()
95218+
this.request.uri = this.formatPath()
9521995219

9522095220
return this.request
9522195221
}
@@ -132736,7 +132736,7 @@ OAuth.prototype.onRequest = function (_oauth) {
132736132736
case 'query':
132737132737
var href = self.request.uri.href += (query ? '&' : '?') + self.concatParams(oa, '&')
132738132738
self.request.uri = url.parse(href)
132739-
self.request.path = self.request.uri.path
132739+
self.request.uri = self.request.uri.path
132740132740
break
132741132741

132742132742
case 'body':
@@ -136105,7 +136105,7 @@ Request.prototype.enableUnixSocket = function () {
136105136105
// Apply unix properties to request
136106136106
this.socketPath = host
136107136107
this.uri.pathname = path
136108-
this.uri.path = path
136108+
this.uri.uri = path
136109136109
this.uri.host = host
136110136110
this.uri.hostname = host
136111136111
this.uri.isUnix = true

packages/uikit-react-native/src/components/MessageRenderer/FileMessage/ImageFileMessage.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ const ImageFileMessage = ({ message, children, variant }: FileMessageProps) => {
4444
const key = useRetry(imageNotFound);
4545

4646
return (
47-
<View style={[styles.bubbleContainer, { backgroundColor: colors.ui.message[variant].enabled.background }]}>
47+
<View
48+
style={[
49+
styles.bubbleContainer,
50+
{ backgroundColor: imageNotFound ? colors.onBackground04 : colors.ui.message[variant].enabled.background },
51+
]}
52+
>
4853
<View style={style}>
4954
<Image
5055
key={key}

packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
100100
) => SendbirdGroupChannelCreateParams | Promise<SendbirdGroupChannelCreateParams>;
101101
};
102102
userMention?: Pick<Partial<MentionConfigInterface>, 'mentionLimit' | 'suggestionLimit' | 'debounceMills'>;
103-
imageCompression?: ImageCompressionConfigInterface;
103+
imageCompression?: Partial<ImageCompressionConfigInterface>;
104104
}>;
105105

106106
const SendbirdUIKitContainer = ({

packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput/SendInput.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
101101
) {
102102
await SBUUtils.safeRun(async () => {
103103
const compressed = await mediaService.compressImage({
104-
path: mediaFile.uri,
104+
uri: mediaFile.uri,
105105
maxWidth: imageCompressionConfig.width,
106106
maxHeight: imageCompressionConfig.height,
107107
compressionRate: imageCompressionConfig.compressionRate,
108108
});
109109

110110
if (compressed) {
111-
mediaFile.uri = compressed.path;
111+
mediaFile.uri = compressed.uri;
112112
mediaFile.size = compressed.size;
113113
}
114114
});
@@ -151,14 +151,14 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
151151
) {
152152
await SBUUtils.safeRun(async () => {
153153
const compressed = await mediaService.compressImage({
154-
path: mediaFile.uri,
154+
uri: mediaFile.uri,
155155
maxWidth: imageCompressionConfig.width,
156156
maxHeight: imageCompressionConfig.height,
157157
compressionRate: imageCompressionConfig.compressionRate,
158158
});
159159

160160
if (compressed) {
161-
mediaFile.uri = compressed.path;
161+
mediaFile.uri = compressed.uri;
162162
mediaFile.size = compressed.size;
163163
}
164164
});
@@ -184,14 +184,14 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
184184
) {
185185
await SBUUtils.safeRun(async () => {
186186
const compressed = await mediaService.compressImage({
187-
path: documentFile.uri,
187+
uri: documentFile.uri,
188188
maxWidth: imageCompressionConfig.width,
189189
maxHeight: imageCompressionConfig.height,
190190
compressionRate: imageCompressionConfig.compressionRate,
191191
});
192192

193193
if (compressed) {
194-
documentFile.uri = compressed.path;
194+
documentFile.uri = compressed.uri;
195195
documentFile.size = compressed.size;
196196
}
197197
});

packages/uikit-react-native/src/platform/createMediaService.expo.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ const createExpoMediaService = ({
3636
return null;
3737
}
3838
},
39-
async compressImage({ maxWidth, maxHeight, compressionRate = 1, path }) {
40-
const originSize = await SBUUtils.getImageSize(path);
39+
async compressImage({ maxWidth, maxHeight, compressionRate = 1, uri }) {
40+
const originSize = await SBUUtils.getImageSize(uri);
4141
const resizingSize = getDownscaleSize(originSize, { width: maxWidth, height: maxHeight });
4242

43-
const { uri } = await imageManipulator.manipulateAsync(path, [{ resize: resizingSize }], {
43+
const { uri: compressedURI } = await imageManipulator.manipulateAsync(uri, [{ resize: resizingSize }], {
4444
compress: Math.min(Math.max(0, compressionRate), 1),
4545
});
4646
const { size = 0 } = await fsModule.getInfoAsync(uri);
4747

48-
return { path: uri, size };
48+
return { uri: compressedURI, size };
4949
},
5050
};
5151
};

packages/uikit-react-native/src/platform/createMediaService.native.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ const createNativeMediaService = ({
3636
return null;
3737
}
3838
},
39-
async compressImage({ path, maxWidth, maxHeight, compressionRate = 1 }) {
40-
const originSize = await SBUUtils.getImageSize(path);
39+
async compressImage({ uri, maxWidth, maxHeight, compressionRate = 1 }) {
40+
const originSize = await SBUUtils.getImageSize(uri);
4141
const { width, height } = getDownscaleSize(originSize, { width: maxWidth, height: maxHeight });
4242
const extension = (() => {
43-
return { 'png': 'PNG', 'jpeg': 'JPEG', 'jpg': 'JPEG' }[getFileExtension(path)] ?? 'JPEG';
43+
return { 'png': 'PNG', 'jpeg': 'JPEG', 'jpg': 'JPEG' }[getFileExtension(uri)] ?? 'JPEG';
4444
})() as 'PNG' | 'JPEG';
4545

46-
const { path: resizedPath, size: resizedSize } = await imageResizerModule.default.createResizedImage(
47-
path,
46+
const { size: resizedSize, uri: compressedURI } = await imageResizerModule.default.createResizedImage(
47+
uri,
4848
width,
4949
height,
5050
extension,
5151
Math.min(Math.max(0, compressionRate), 1) * 100,
5252
);
5353

54-
return { path: resizedPath, size: resizedSize };
54+
return { uri: compressedURI, size: resizedSize };
5555
},
5656
};
5757
};

packages/uikit-react-native/src/platform/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ interface GetVideoThumbnailOptions {
6969

7070
interface CompressImageOptions {
7171
/**
72-
* A path of image file to compress
72+
* A uri of image file to compress
7373
* */
74-
path: string;
74+
uri: string;
7575

7676
/**
7777
* A resize width, apply only to downscale
@@ -91,7 +91,7 @@ interface CompressImageOptions {
9191
}
9292

9393
type GetVideoThumbnailResult = Promise<{ path: string } | null>;
94-
type CompressImageResult = Promise<{ path: string; size: number } | null>;
94+
type CompressImageResult = Promise<{ uri: string; size: number } | null>;
9595

9696
export interface MediaServiceInterface {
9797
VideoComponent<Props = {}>(props: VideoProps & Props): JSX.Element;

0 commit comments

Comments
 (0)