[skip ci] feat: prepare for public release
This commit is contained in:
@@ -23,8 +23,11 @@ import {PhoneIcon, VideoCameraIcon} from '@phosphor-icons/react';
|
||||
import {observer} from 'mobx-react-lite';
|
||||
import React from 'react';
|
||||
import * as CallActionCreators from '~/actions/CallActionCreators';
|
||||
import * as ToastActionCreators from '~/actions/ToastActionCreators';
|
||||
import {ChannelTypes} from '~/Constants';
|
||||
import type {ChannelRecord} from '~/records/ChannelRecord';
|
||||
import CallStateStore from '~/stores/CallStateStore';
|
||||
import UserStore from '~/stores/UserStore';
|
||||
import MediaEngineStore from '~/stores/voice/MediaEngineFacade';
|
||||
import * as CallUtils from '~/utils/CallUtils';
|
||||
import {ChannelHeaderIcon} from './ChannelHeaderIcon';
|
||||
@@ -38,9 +41,20 @@ const VoiceCallButton = observer(({channel}: {channel: ChannelRecord}) => {
|
||||
const hasActiveCall = CallStateStore.hasActiveCall(channel.id);
|
||||
const participants = call ? CallStateStore.getParticipants(channel.id) : [];
|
||||
const participantCount = participants.length;
|
||||
const currentUser = UserStore.getCurrentUser();
|
||||
const isUnclaimed = !(currentUser?.isClaimed() ?? false);
|
||||
const is1to1 = channel.type === ChannelTypes.DM;
|
||||
const blocked = isUnclaimed && is1to1;
|
||||
|
||||
const handleClick = React.useCallback(
|
||||
async (event: React.MouseEvent) => {
|
||||
if (blocked) {
|
||||
ToastActionCreators.createToast({
|
||||
type: 'error',
|
||||
children: t`Claim your account to start or join 1:1 calls.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (isInCall) {
|
||||
void CallActionCreators.leaveCall(channel.id);
|
||||
} else if (hasActiveCall) {
|
||||
@@ -50,7 +64,7 @@ const VoiceCallButton = observer(({channel}: {channel: ChannelRecord}) => {
|
||||
await CallUtils.checkAndStartCall(channel.id, silent);
|
||||
}
|
||||
},
|
||||
[channel.id, isInCall, hasActiveCall],
|
||||
[channel.id, isInCall, hasActiveCall, blocked],
|
||||
);
|
||||
|
||||
let label: string;
|
||||
@@ -67,7 +81,13 @@ const VoiceCallButton = observer(({channel}: {channel: ChannelRecord}) => {
|
||||
: t`Join Voice Call (${participantCount} participants)`;
|
||||
}
|
||||
} else {
|
||||
label = isInCall ? t`Leave Voice Call` : hasActiveCall ? t`Join Voice Call` : t`Start Voice Call`;
|
||||
label = blocked
|
||||
? t`Claim your account to call`
|
||||
: isInCall
|
||||
? t`Leave Voice Call`
|
||||
: hasActiveCall
|
||||
? t`Join Voice Call`
|
||||
: t`Start Voice Call`;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -76,6 +96,7 @@ const VoiceCallButton = observer(({channel}: {channel: ChannelRecord}) => {
|
||||
label={label}
|
||||
isSelected={isInCall}
|
||||
onClick={handleClick}
|
||||
disabled={blocked}
|
||||
keybindAction="start_pm_call"
|
||||
/>
|
||||
);
|
||||
@@ -90,9 +111,20 @@ const VideoCallButton = observer(({channel}: {channel: ChannelRecord}) => {
|
||||
const hasActiveCall = CallStateStore.hasActiveCall(channel.id);
|
||||
const participants = call ? CallStateStore.getParticipants(channel.id) : [];
|
||||
const participantCount = participants.length;
|
||||
const currentUser = UserStore.getCurrentUser();
|
||||
const isUnclaimed = !(currentUser?.isClaimed() ?? false);
|
||||
const is1to1 = channel.type === ChannelTypes.DM;
|
||||
const blocked = isUnclaimed && is1to1;
|
||||
|
||||
const handleClick = React.useCallback(
|
||||
async (event: React.MouseEvent) => {
|
||||
if (blocked) {
|
||||
ToastActionCreators.createToast({
|
||||
type: 'error',
|
||||
children: t`Claim your account to start or join 1:1 calls.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (isInCall) {
|
||||
void CallActionCreators.leaveCall(channel.id);
|
||||
} else if (hasActiveCall) {
|
||||
@@ -102,7 +134,7 @@ const VideoCallButton = observer(({channel}: {channel: ChannelRecord}) => {
|
||||
await CallUtils.checkAndStartCall(channel.id, silent);
|
||||
}
|
||||
},
|
||||
[channel.id, isInCall, hasActiveCall],
|
||||
[channel.id, isInCall, hasActiveCall, blocked],
|
||||
);
|
||||
|
||||
let label: string;
|
||||
@@ -119,10 +151,24 @@ const VideoCallButton = observer(({channel}: {channel: ChannelRecord}) => {
|
||||
: t`Join Video Call (${participantCount} participants)`;
|
||||
}
|
||||
} else {
|
||||
label = isInCall ? t`Leave Video Call` : hasActiveCall ? t`Join Video Call` : t`Start Video Call`;
|
||||
label = blocked
|
||||
? t`Claim your account to call`
|
||||
: isInCall
|
||||
? t`Leave Video Call`
|
||||
: hasActiveCall
|
||||
? t`Join Video Call`
|
||||
: t`Start Video Call`;
|
||||
}
|
||||
|
||||
return <ChannelHeaderIcon icon={VideoCameraIcon} label={label} isSelected={isInCall} onClick={handleClick} />;
|
||||
return (
|
||||
<ChannelHeaderIcon
|
||||
icon={VideoCameraIcon}
|
||||
label={label}
|
||||
isSelected={isInCall}
|
||||
onClick={handleClick}
|
||||
disabled={blocked}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const CallButtons = {
|
||||
|
||||
Reference in New Issue
Block a user