Calls incompatibility toast
This commit is contained in:
parent
15b7d1afc9
commit
634c0bc55b
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import replaceContent from "../helpers/dom/replaceContent";
|
||||
import { i18n, LangPackKey } from "../lib/langPack";
|
||||
import { FormatterArguments, i18n, LangPackKey } from "../lib/langPack";
|
||||
|
||||
const toastEl = document.createElement('div');
|
||||
toastEl.classList.add('toast');
|
||||
@ -21,7 +21,8 @@ export function toast(content: string | Node) {
|
||||
}
|
||||
|
||||
export function toastNew(options: Partial<{
|
||||
langPackKey: LangPackKey
|
||||
langPackKey: LangPackKey,
|
||||
langPackArguments: FormatterArguments
|
||||
}>) {
|
||||
toast(i18n(options.langPackKey));
|
||||
toast(i18n(options.langPackKey, options.langPackArguments));
|
||||
}
|
||||
|
@ -688,6 +688,7 @@ const lang = {
|
||||
"PrivacyPhoneInfo4": "This public link opens a chat with you:",
|
||||
"ReportChatIllegalDrugs": "Illegal Drugs",
|
||||
"ReportChatPersonalDetails": "Personal Details",
|
||||
"VoipPeerIncompatible": "**%1$s**'s app is using an incompatible protocol. They need to update their app before you can call them.",
|
||||
|
||||
// * macos
|
||||
"AccountSettings.Filters": "Chat Folders",
|
||||
|
@ -15,12 +15,14 @@ import indexOfAndSplice from "../../helpers/array/indexOfAndSplice";
|
||||
import insertInDescendSortedArray from "../../helpers/array/insertInDescendSortedArray";
|
||||
import AudioAssetPlayer from "../../helpers/audioAssetPlayer";
|
||||
import bytesCmp from "../../helpers/bytes/bytesCmp";
|
||||
import compareVersion from "../../helpers/compareVersion";
|
||||
import safeReplaceObject from "../../helpers/object/safeReplaceObject";
|
||||
import { nextRandomUint } from "../../helpers/random";
|
||||
import tsNow from "../../helpers/tsNow";
|
||||
import { InputPhoneCall, MessagesDhConfig, PhoneCall, PhoneCallDiscardReason, PhoneCallProtocol, PhonePhoneCall } from "../../layer";
|
||||
import CallInstance from "../calls/callInstance";
|
||||
import CALL_STATE from "../calls/callState";
|
||||
import getCallProtocol from "../calls/p2P/getCallProtocol";
|
||||
import { logger } from "../logger";
|
||||
import apiManager from "../mtproto/mtprotoworker";
|
||||
import { NULL_PEER_ID } from "../mtproto/mtproto_config";
|
||||
@ -74,6 +76,12 @@ export class AppCallsManager {
|
||||
|
||||
case 'phoneCallAccepted': {
|
||||
if(instance) {
|
||||
if(!this.verifyProtocolCompatibility(call.protocol)) {
|
||||
instance.hangUp('phoneCallDiscardReasonDisconnect');
|
||||
rootScope.dispatchEvent('call_incompatible', instance.interlocutorUserId);
|
||||
break;
|
||||
}
|
||||
|
||||
instance.confirmCall();
|
||||
}
|
||||
|
||||
@ -82,6 +90,11 @@ export class AppCallsManager {
|
||||
|
||||
case 'phoneCallRequested': {
|
||||
if(!instance) {
|
||||
if(!this.verifyProtocolCompatibility(call.protocol)) {
|
||||
rootScope.dispatchEvent('call_incompatible', call.admin_id);
|
||||
break;
|
||||
}
|
||||
|
||||
instance = this.createCallInstance({
|
||||
isOutgoing: false,
|
||||
interlocutorUserId: call.admin_id
|
||||
@ -324,6 +337,14 @@ export class AppCallsManager {
|
||||
});
|
||||
}
|
||||
|
||||
private verifyProtocolCompatibility(protocol: PhoneCallProtocol) {
|
||||
const my = getCallProtocol();
|
||||
const myVersion = my.library_versions[0];
|
||||
return !protocol.library_versions.find(version => {
|
||||
return compareVersion(myVersion, version) > 0;
|
||||
});
|
||||
}
|
||||
|
||||
public async discardCall(callId: CallId, duration: number, reason: PhoneCallDiscardReason['_'], video?: boolean) {
|
||||
if(!this.getCall(callId)) {
|
||||
return;
|
||||
|
@ -377,6 +377,15 @@ export class AppImManager {
|
||||
|
||||
popup.show();
|
||||
});
|
||||
|
||||
rootScope.addEventListener('call_incompatible', (userId) => {
|
||||
toastNew({
|
||||
langPackKey: 'VoipPeerIncompatible',
|
||||
langPackArguments: [
|
||||
new PeerTitle({peerId: userId.toPeerId()}).element
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ! do not remove this line
|
||||
|
@ -14,6 +14,7 @@ import type { ApiUpdatesManager } from "../appManagers/apiUpdatesManager";
|
||||
import type { AppCallsManager, CallId } from "../appManagers/appCallsManager";
|
||||
import { logger } from "../logger";
|
||||
import type { ApiManagerProxy } from "../mtproto/mtprotoworker";
|
||||
import rootScope from "../rootScope";
|
||||
import CallConnectionInstance from "./callConnectionInstance";
|
||||
import CallInstanceBase from "./callInstanceBase";
|
||||
import CALL_STATE from "./callState";
|
||||
@ -847,6 +848,7 @@ export default class CallInstance extends CallInstanceBase<{
|
||||
} catch(err) {
|
||||
this.log.error('wrong signaling data', str);
|
||||
this.hangUp('phoneCallDiscardReasonDisconnect');
|
||||
rootScope.dispatchEvent('call_incompatible', this.interlocutorUserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +160,7 @@ export type BroadcastEvents = {
|
||||
|
||||
'call_instance': {hasCurrent: boolean, instance: CallInstance},
|
||||
'call_accepting': CallInstance, // это костыль. используется при параллельном вызове, чтобы заменить звонок в topbarCall
|
||||
'call_incompatible': UserId,
|
||||
|
||||
'quick_reaction': string,
|
||||
|
||||
|
@ -372,7 +372,7 @@ ul.chatlist {
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
line-height: 1;
|
||||
font-size: 1.25rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.media-photo {
|
||||
|
Loading…
Reference in New Issue
Block a user