Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Change AudioPreview stop() return type. #255

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ class RNAudioPreviewModule(

/**
* Stops recording or playing an audio sample.
* @param promise returns null
* @param promise returns Boolean.
*/
@ReactMethod
fun stop(promise: ReactPromise) {
Promises.promise({ localAudio.preview().stop() })
.forward(promise, ignoreReturnType = true)
.forward(promise)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions docs/classes/internal.AudioPreview.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ ___

### stop

▸ **stop**(): `Promise`<`void`\>
▸ **stop**(): `Promise`<`boolean`\>

Stops recording or playing an audio sample.

#### Returns

`Promise`<`void`\>
`Promise`<`boolean`\>

___

Expand Down
4 changes: 2 additions & 2 deletions example/src/utils/audioPreview.testers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const play = async () => {

export const stop = async () => {
try {
await CommsAPI.audio.getLocal().preview().stop();
console.log('Stop success');
const stop = await CommsAPI.audio.getLocal().preview().stop();
console.log('Stop: ', stop.toString());
} catch (e: any) {
console.log(e);
Alert.alert(`Error ${JSON.stringify(e)}`);
Expand Down
6 changes: 2 additions & 4 deletions ios/Services/AudioService/AudioPreviewServiceModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ public class AudioPreviewServiceModule: ReactEmitter {
resolve: @escaping RCTPromiseResolveBlock,
reject: @escaping RCTPromiseRejectBlock
) {
if !VoxeetSDK.shared.audio.local.preview.stop() {
ModuleError.audioPreviewGenericError.send(with: reject)
}
resolve(nil)
let stop = VoxeetSDK.shared.audio.local.preview.stop()
resolve(stop)
}

@objc(release:rejecter:)
Expand Down
2 changes: 1 addition & 1 deletion src/services/audio/AudioPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class AudioPreview {
/**
* Stops recording or playing an audio sample.
*/
public async stop(): Promise<void> {
public async stop(): Promise<boolean> {
return this._audioPreview.stop();
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/audio/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('AudioPreview', () => {
describe('stop()', () => {
it('should invoke exported stop method', () => {
CommsAPIAudioPreviewModule.stop.mockImplementation(() =>
Promise.resolve()
Promise.resolve(true)
);
AudioPreview.stop();
expect(CommsAPIAudioPreviewModule.stop).toHaveBeenCalled();
Expand Down