Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release/v3.2.3' into release/v…
Browse files Browse the repository at this point in the history
…3.2.3
  • Loading branch information
ptchayap committed Mar 1, 2024
2 parents e62a5f5 + 85d0194 commit f795ae7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
release_as:
description: 'release as'
required: true
custom_version:
description: 'custom version'
required: false

jobs:
publish:
Expand Down Expand Up @@ -53,6 +56,10 @@ jobs:
run: pnpm standard-version --yes --release-as major
if: github.event.inputs.release_as == 'major'

- name: increase version (custom)
run: pnpm standard-version --yes --release-as ${{ github.event.inputs.custom_version }}
if: github.event.inputs.release_as == 'custom'

- name: build
run: pnpm run build

Expand Down
35 changes: 20 additions & 15 deletions src/core/providers/UiKitProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ interface UiKitProviderProps {
http?: string;
mqtt?: string;
};
authToken?: string;
userId: string;
displayName: string;
customComponents?: CustomComponentType;
Expand All @@ -47,13 +46,13 @@ interface UiKitProviderProps {
onConnectionStatusChange?: (state: Amity.SessionStates) => void;
onConnected?: () => void;
onDisconnected?: () => void;
getAuthToken?: () => Promise<string>;
}

const UiKitProvider = ({
apiKey,
apiRegion,
apiEndpoint,
authToken,
userId,
displayName,
customComponents = {},
Expand All @@ -64,6 +63,7 @@ const UiKitProvider = ({
actionHandlers,
onConnectionStatusChange,
onDisconnected,
getAuthToken,
}: UiKitProviderProps) => {
const [isConnected, setIsConnected] = useState(false);
const [client, setClient] = useState<Amity.Client | null>(null);
Expand Down Expand Up @@ -95,20 +95,25 @@ const UiKitProvider = ({
const currentIsConnected = ASCClient.isConnected();

if (!currentIsConnected) {
await ASCClient.login(
{ userId, displayName, authToken },
{
sessionWillRenewAccessToken(renewal) {
// secure mode
if (authToken) {
renewal.renewWithAuthToken(authToken);
return;
}

renewal.renew();
},
let params: Amity.ConnectClientParams = { userId, displayName };

if (getAuthToken) {
const authToken = await getAuthToken();
params = { ...params, authToken };
}

await ASCClient.login(params, {
async sessionWillRenewAccessToken(renewal: Amity.AccessTokenRenewal) {
// secure mode
if (getAuthToken) {
const authToken = await getAuthToken();
renewal.renewWithAuthToken(authToken);
return;
}

renewal.renew();
},
);
});
}

setIsConnected(true);
Expand Down

0 comments on commit f795ae7

Please sign in to comment.