diff --git a/.eslintignore b/.eslintignore index 96171e5..c9c978c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,3 +5,4 @@ .snapshots/ lib/ src/ti/ +docs diff --git a/example/src/advanced/Lock/index.tsx b/example/src/advanced/Lock/index.tsx index f1e23ce..d578b35 100644 --- a/example/src/advanced/Lock/index.tsx +++ b/example/src/advanced/Lock/index.tsx @@ -2,14 +2,10 @@ import { IStreamChannel, JoinChannelOptions, LockDetail, - MetadataItem, - MetadataOptions, RTM_CHANNEL_TYPE, RTM_CONNECTION_CHANGE_REASON, RTM_CONNECTION_STATE, RTM_ERROR_CODE, - RtmMetadata, - StorageEvent, } from 'agora-react-native-rtm'; import React, { useCallback, useEffect, useRef, useState } from 'react'; @@ -18,12 +14,9 @@ import { ScrollView } from 'react-native'; import BaseComponent from '../../components/BaseComponent'; import { AgoraButton, - AgoraCard, - AgoraList, AgoraStyle, AgoraText, AgoraTextInput, - AgoraView, } from '../../components/ui'; import Config from '../../config/agora.config'; import { useRtmClient } from '../../hooks/useRtmClient'; @@ -32,7 +25,6 @@ import * as log from '../../utils/log'; export default function Lock() { const [loginSuccess, setLoginSuccess] = useState(false); const [joinSuccess, setJoinSuccess] = useState(false); - const [acquireLockSuccess, setAcquireLockSuccess] = useState(false); const [streamChannel, setStreamChannel] = useState(); const [cName, setCName] = useState(Config.channelName); const acquireLockRequestId = useRef(); @@ -97,12 +89,31 @@ export default function Lock() { if (errorCode !== RTM_ERROR_CODE.RTM_ERROR_OK) { log.error(`acquire lock failed`, `errorCode: ${errorCode}`); } - if ( - requestId === acquireLockRequestId.current && - errorCode === RTM_ERROR_CODE.RTM_ERROR_OK - ) { - setAcquireLockSuccess(true); - } + }, + [] + ); + + const onReleaseLockResult = useCallback( + ( + requestId: number, + channelName: string, + channelType: RTM_CHANNEL_TYPE, + _lockName: string, + errorCode: RTM_ERROR_CODE + ) => { + log.info( + 'onAcquireLockResult', + 'requestId', + requestId, + 'channelName', + channelName, + 'channelType', + channelType, + 'lockName', + _lockName, + 'errorCode', + errorCode + ); }, [] ); @@ -341,6 +352,7 @@ export default function Lock() { client.addEventListener('onJoinResult', onJoinResult); client.addEventListener('onSetLockResult', onSetLockResult); client?.addEventListener('onAcquireLockResult', onAcquireLockResult); + client?.addEventListener('onReleaseLockResult', onReleaseLockResult); client?.addEventListener('onRevokeLockResult', onRevokeLockResult); client?.addEventListener('onRemoveLockResult', onRemoveLockResult); client?.addEventListener('onGetLocksResult', onGetLocksResult); @@ -349,6 +361,7 @@ export default function Lock() { client.removeEventListener('onJoinResult', onJoinResult); client.removeEventListener('onSetLockResult', onSetLockResult); client?.removeEventListener('onAcquireLockResult', onAcquireLockResult); + client?.removeEventListener('onReleaseLockResult', onReleaseLockResult); client?.removeEventListener('onRevokeLockResult', onRevokeLockResult); client?.removeEventListener('onRemoveLockResult', onRemoveLockResult); client?.removeEventListener('onGetLocksResult', onGetLocksResult); @@ -359,6 +372,7 @@ export default function Lock() { onJoinResult, onSetLockResult, onAcquireLockResult, + onReleaseLockResult, onRevokeLockResult, onRemoveLockResult, onGetLocksResult, @@ -389,7 +403,6 @@ export default function Lock() { RTM_CONNECTION_CHANGE_REASON.RTM_CONNECTION_CHANGED_LOGOUT ) { setLoginSuccess(false); - setAcquireLockSuccess(false); destroyStreamChannel(); } setJoinSuccess(false); diff --git a/example/src/basic/createStreamChannel/index.tsx b/example/src/basic/createStreamChannel/index.tsx index 28f2372..0100d26 100644 --- a/example/src/basic/createStreamChannel/index.tsx +++ b/example/src/basic/createStreamChannel/index.tsx @@ -10,7 +10,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { KeyboardAvoidingView, Platform, ScrollView } from 'react-native'; import BaseComponent from '../../components/BaseComponent'; -import { AgoraButton, AgoraStyle, AgoraView } from '../../components/ui'; +import { AgoraButton, AgoraStyle } from '../../components/ui'; import Config from '../../config/agora.config'; import { useRtmClient } from '../../hooks/useRtmClient'; import * as log from '../../utils/log'; diff --git a/typedoc.json b/typedoc.json index ff06abd..d29300d 100644 --- a/typedoc.json +++ b/typedoc.json @@ -4,5 +4,8 @@ "includeVersion": true, "hideGenerator": true, "includes": "./src", - "exclude": ["**/scripts/terra/**/*"] + "exclude": ["**/scripts/terra/**/*"], + "compilerOptions": { + "noUnusedLocals": false + } }