Skip to content

Commit 4bbea1f

Browse files
author
Isaac
committed
Conference improvements
1 parent 0d4b8ee commit 4bbea1f

File tree

25 files changed

+506
-219
lines changed

25 files changed

+506
-219
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14188,3 +14188,8 @@ Sorry for the inconvenience.";
1418814188
"SendInviteLink.TextCallsRestrictedMultipleUsers_1" = "{user_list}, and **%d** more person do not accept calls.";
1418914189
"SendInviteLink.TextCallsRestrictedMultipleUsers_any" = "{user_list}, and **%d** more people do not accept calls.";
1419014190
"SendInviteLink.TextCallsRestrictedSendInviteLink" = "You can try to send an invite link instead.";
14191+
14192+
"Call.VoiceChatInProgressConferenceMessage" = "Leave voice chat in %1$@ and start a conference?";
14193+
"Call.LiveStreamInProgressConferenceMessage" = "Leave live stream in %1$@ and start a conference?";
14194+
14195+
"VoiceChat.RemoveConferencePeerConfirmation" = "Are you sure you want to remove %@ from this call?";

submodules/AccountContext/Sources/AccountContext.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,14 +964,16 @@ public enum JoinSubjectScreenMode {
964964
public let inviter: EnginePeer?
965965
public let members: [EnginePeer]
966966
public let totalMemberCount: Int
967+
public let info: JoinCallLinkInformation
967968

968-
public init(id: Int64, accessHash: Int64, slug: String, inviter: EnginePeer?, members: [EnginePeer], totalMemberCount: Int) {
969+
public init(id: Int64, accessHash: Int64, slug: String, inviter: EnginePeer?, members: [EnginePeer], totalMemberCount: Int, info: JoinCallLinkInformation) {
969970
self.id = id
970971
self.accessHash = accessHash
971972
self.slug = slug
972973
self.inviter = inviter
973974
self.members = members
974975
self.totalMemberCount = totalMemberCount
976+
self.info = info
975977
}
976978
}
977979

@@ -1325,6 +1327,7 @@ public protocol AccountContext: AnyObject {
13251327

13261328
func scheduleGroupCall(peerId: PeerId, parentController: ViewController)
13271329
func joinGroupCall(peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, activeCall: EngineGroupCallDescription)
1330+
func joinConferenceCall(call: JoinCallLinkInformation, isVideo: Bool)
13281331
func requestCall(peerId: PeerId, isVideo: Bool, completion: @escaping () -> Void)
13291332
}
13301333

submodules/AccountContext/Sources/PresentationCallManager.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ public protocol PresentationCallManager: AnyObject {
579579
initialCall: EngineGroupCallDescription,
580580
reference: InternalGroupCallReference,
581581
beginWithVideo: Bool,
582-
invitePeerIds: [EnginePeer.Id]
583-
)
582+
invitePeerIds: [EnginePeer.Id],
583+
endCurrentIfAny: Bool
584+
) -> JoinGroupCallManagerResult
584585
}

submodules/CallListUI/Sources/CallListController.swift

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public final class CallListController: TelegramBaseController {
210210
}
211211

212212
private func createGroupCall(peerIds: [EnginePeer.Id], isVideo: Bool, completion: (() -> Void)? = nil) {
213-
self.view.endEditing(true)
213+
self.view.window?.endEditing(true)
214214

215215
guard !self.presentAccountFrozenInfoIfNeeded() else {
216216
return
@@ -264,7 +264,7 @@ public final class CallListController: TelegramBaseController {
264264
guard let self else {
265265
return
266266
}
267-
self.context.sharedContext.callManager?.joinConferenceCall(
267+
let _ = self.context.sharedContext.callManager?.joinConferenceCall(
268268
accountContext: self.context,
269269
initialCall: EngineGroupCallDescription(
270270
id: call.callInfo.id,
@@ -276,7 +276,8 @@ public final class CallListController: TelegramBaseController {
276276
),
277277
reference: .id(id: call.callInfo.id, accessHash: call.callInfo.accessHash),
278278
beginWithVideo: isVideo,
279-
invitePeerIds: peerIds
279+
invitePeerIds: peerIds,
280+
endCurrentIfAny: true
280281
)
281282
completion?()
282283
}
@@ -712,20 +713,7 @@ public final class CallListController: TelegramBaseController {
712713
guard let self else {
713714
return
714715
}
715-
self.context.sharedContext.callManager?.joinConferenceCall(
716-
accountContext: self.context,
717-
initialCall: EngineGroupCallDescription(
718-
id: resolvedCallLink.id,
719-
accessHash: resolvedCallLink.accessHash,
720-
title: nil,
721-
scheduleTimestamp: nil,
722-
subscribedToScheduled: false,
723-
isStream: false
724-
),
725-
reference: .message(id: message.id),
726-
beginWithVideo: conferenceCall.flags.contains(.isVideo),
727-
invitePeerIds: []
728-
)
716+
self.context.joinConferenceCall(call: resolvedCallLink, isVideo: conferenceCall.flags.contains(.isVideo))
729717
}, error: { [weak self] error in
730718
guard let self else {
731719
return

submodules/ContactListUI/Sources/ContactListNode.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
799799
return entries
800800
}
801801

802-
private func preparedContactListNodeTransition(context: AccountContext, presentationData: PresentationData, from fromEntries: [ContactListNodeEntry], to toEntries: [ContactListNodeEntry], interaction: ContactListNodeInteraction, firstTime: Bool, isEmpty: Bool, generateIndexSections: Bool, animation: ContactListAnimation, isSearch: Bool) -> ContactsListNodeTransition {
802+
private func preparedContactListNodeTransition(context: AccountContext, presentationData: PresentationData, from fromEntries: [ContactListNodeEntry], to toEntries: [ContactListNodeEntry], interaction: ContactListNodeInteraction, firstTime: Bool, isEmpty: Bool, hasOptions: Bool, generateIndexSections: Bool, animation: ContactListAnimation, isSearch: Bool) -> ContactsListNodeTransition {
803803
let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries)
804804

805805
let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) }
@@ -848,7 +848,7 @@ private func preparedContactListNodeTransition(context: AccountContext, presenta
848848
scrollToItem = ListViewScrollToItem(index: 0, position: .top(-50.0), animated: false, curve: .Default(duration: 0.0), directionHint: .Up)
849849
}
850850

851-
return ContactsListNodeTransition(deletions: deletions, insertions: insertions, updates: updates, indexSections: indexSections, firstTime: firstTime, isEmpty: isEmpty, scrollToItem: scrollToItem, animation: animation)
851+
return ContactsListNodeTransition(deletions: deletions, insertions: insertions, updates: updates, indexSections: indexSections, firstTime: firstTime, isEmpty: isEmpty, hasOptions: hasOptions, scrollToItem: scrollToItem, animation: animation)
852852
}
853853

854854
private struct ContactsListNodeTransition {
@@ -858,6 +858,7 @@ private struct ContactsListNodeTransition {
858858
let indexSections: [String]
859859
let firstTime: Bool
860860
let isEmpty: Bool
861+
let hasOptions: Bool
861862
let scrollToItem: ListViewScrollToItem?
862863
let animation: ContactListAnimation
863864
}
@@ -1184,7 +1185,7 @@ public final class ContactListNode: ASDisplayNode {
11841185
authorizeImpl?()
11851186
}, openPrivacyPolicy: {
11861187
openPrivacyPolicyImpl?()
1187-
})
1188+
}, filterHitTest: true)
11881189
self.authorizationNode.isHidden = true
11891190

11901191
super.init()
@@ -1644,7 +1645,7 @@ public final class ContactListNode: ASDisplayNode {
16441645

16451646
let entries = contactListNodeEntries(accountPeer: nil, peers: peers, presences: localPeersAndStatuses.1, presentation: presentation, selectionState: selectionState, theme: presentationData.theme, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, disabledPeerIds: disabledPeerIds, peerRequiresPremiumForMessaging: peerRequiresPremiumForMessaging, peersWithStories: [:], authorizationStatus: .allowed, warningSuppressed: (true, true), displaySortOptions: false, displayCallIcons: displayCallIcons, storySubscriptions: nil, topPeers: [], topPeersPresentation: .none, isPeerEnabled: isPeerEnabled, interaction: interaction)
16461647
let previous = previousEntries.swap(entries)
1647-
return .single(preparedContactListNodeTransition(context: context, presentationData: presentationData, from: previous ?? [], to: entries, interaction: interaction, firstTime: previous == nil, isEmpty: false, generateIndexSections: generateSections, animation: .none, isSearch: isSearch))
1648+
return .single(preparedContactListNodeTransition(context: context, presentationData: presentationData, from: previous ?? [], to: entries, interaction: interaction, firstTime: previous == nil, isEmpty: false, hasOptions: false, generateIndexSections: generateSections, animation: .none, isSearch: isSearch))
16481649
}
16491650

16501651
if OSAtomicCompareAndSwap32(1, 0, &firstTime) {
@@ -1885,7 +1886,7 @@ public final class ContactListNode: ASDisplayNode {
18851886
animation = .none
18861887
}
18871888

1888-
return .single(preparedContactListNodeTransition(context: context, presentationData: presentationData, from: previous ?? [], to: entries, interaction: interaction, firstTime: previous == nil, isEmpty: isEmpty, generateIndexSections: generateSections, animation: animation, isSearch: isSearch))
1889+
return .single(preparedContactListNodeTransition(context: context, presentationData: presentationData, from: previous ?? [], to: entries, interaction: interaction, firstTime: previous == nil, isEmpty: isEmpty, hasOptions: optionsCount != 0, generateIndexSections: generateSections, animation: animation, isSearch: isSearch))
18891890
}
18901891

18911892
if OSAtomicCompareAndSwap32(1, 0, &firstTime) {
@@ -1921,7 +1922,7 @@ public final class ContactListNode: ASDisplayNode {
19211922
authorizeImpl?()
19221923
}, openPrivacyPolicy: {
19231924
openPrivacyPolicyImpl?()
1924-
})
1925+
}, filterHitTest: true)
19251926
strongSelf.authorizationNode.isHidden = authorizationPreviousHidden
19261927
strongSelf.addSubnode(strongSelf.authorizationNode)
19271928

@@ -2125,7 +2126,7 @@ public final class ContactListNode: ASDisplayNode {
21252126
}
21262127
})
21272128

2128-
self.listNode.isHidden = self.displayPermissionPlaceholder && transition.isEmpty
2129+
self.listNode.isHidden = self.displayPermissionPlaceholder && (transition.isEmpty && !transition.hasOptions)
21292130
self.authorizationNode.isHidden = !transition.isEmpty || !self.displayPermissionPlaceholder
21302131
}
21312132
}

submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ public final class InviteLinkInviteController: ViewController {
589589
}
590590
return false
591591
}), in: .window(.root))
592+
593+
strongSelf.controller?.dismiss()
592594
}
593595
})
594596
}

submodules/Postbox/Sources/SqliteValueBox.swift

Lines changed: 11 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct SqlitePreparedStatement {
149149
}
150150
}
151151

152-
private let dabaseFileNames: [String] = [
152+
private let databaseFileNames: [String] = [
153153
"db_sqlite",
154154
"db_sqlite-shm",
155155
"db_sqlite-wal"
@@ -194,7 +194,6 @@ public final class SqliteValueBox: ValueBox {
194194
private var insertOrIgnorePrimaryKeyStatements: [Int32 : SqlitePreparedStatement] = [:]
195195
private var insertOrIgnoreIndexKeyStatements: [Int32 : SqlitePreparedStatement] = [:]
196196
private var deleteStatements: [Int32 : SqlitePreparedStatement] = [:]
197-
private var moveStatements: [Int32 : SqlitePreparedStatement] = [:]
198197
private var copyStatements: [TablePairKey : SqlitePreparedStatement] = [:]
199198
private var fullTextInsertStatements: [Int32 : SqlitePreparedStatement] = [:]
200199
private var fullTextDeleteStatements: [Int32 : SqlitePreparedStatement] = [:]
@@ -347,7 +346,7 @@ public final class SqliteValueBox: ValueBox {
347346
return nil
348347
}
349348

350-
for fileName in dabaseFileNames {
349+
for fileName in databaseFileNames {
351350
let _ = try? FileManager.default.removeItem(atPath: basePath + "/\(fileName)")
352351
}
353352
database = Database(path, readOnly: false)!
@@ -367,7 +366,7 @@ public final class SqliteValueBox: ValueBox {
367366
}
368367

369368
assert(false)
370-
for fileName in dabaseFileNames {
369+
for fileName in databaseFileNames {
371370
let _ = try? FileManager.default.removeItem(atPath: basePath + "/\(fileName)")
372371
}
373372

@@ -400,7 +399,7 @@ public final class SqliteValueBox: ValueBox {
400399
if self.isEncrypted(database) {
401400
postboxLog("Reencryption failed")
402401

403-
for fileName in dabaseFileNames {
402+
for fileName in databaseFileNames {
404403
let _ = try? FileManager.default.removeItem(atPath: basePath + "/\(fileName)")
405404
}
406405
database = Database(path, readOnly: false)!
@@ -427,7 +426,7 @@ public final class SqliteValueBox: ValueBox {
427426
return nil
428427
}
429428

430-
for fileName in dabaseFileNames {
429+
for fileName in databaseFileNames {
431430
let _ = try? FileManager.default.removeItem(atPath: basePath + "/\(fileName)")
432431
}
433432
database = Database(path, readOnly: false)!
@@ -1224,7 +1223,7 @@ public final class SqliteValueBox: ValueBox {
12241223
preconditionFailure(errorText)
12251224
}
12261225
let preparedStatement = SqlitePreparedStatement(statement: statement)
1227-
self.insertOrReplacePrimaryKeyStatements[table.table.id] = preparedStatement
1226+
self.insertOrReplaceIndexKeyStatements[table.table.id] = preparedStatement
12281227
resultStatement = preparedStatement
12291228
}
12301229
}
@@ -1279,7 +1278,7 @@ public final class SqliteValueBox: ValueBox {
12791278
preconditionFailure(errorText)
12801279
}
12811280
let preparedStatement = SqlitePreparedStatement(statement: statement)
1282-
self.insertOrIgnorePrimaryKeyStatements[table.table.id] = preparedStatement
1281+
self.insertOrIgnoreIndexKeyStatements[table.table.id] = preparedStatement
12831282
resultStatement = preparedStatement
12841283
}
12851284
}
@@ -1330,38 +1329,6 @@ public final class SqliteValueBox: ValueBox {
13301329
return resultStatement
13311330
}
13321331

1333-
private func moveStatement(_ table: ValueBoxTable, from previousKey: ValueBoxKey, to updatedKey: ValueBoxKey) -> SqlitePreparedStatement {
1334-
precondition(self.queue.isCurrent())
1335-
checkTableKey(table, previousKey)
1336-
checkTableKey(table, updatedKey)
1337-
1338-
let resultStatement: SqlitePreparedStatement
1339-
1340-
if let statement = self.moveStatements[table.id] {
1341-
resultStatement = statement
1342-
} else {
1343-
var statement: OpaquePointer? = nil
1344-
let status = sqlite3_prepare_v3(self.database.handle, "UPDATE t\(table.id) SET key=? WHERE key=?", -1, SQLITE_PREPARE_PERSISTENT, &statement, nil)
1345-
precondition(status == SQLITE_OK)
1346-
let preparedStatement = SqlitePreparedStatement(statement: statement)
1347-
self.moveStatements[table.id] = preparedStatement
1348-
resultStatement = preparedStatement
1349-
}
1350-
1351-
resultStatement.reset()
1352-
1353-
switch table.keyType {
1354-
case .binary:
1355-
resultStatement.bind(1, data: previousKey.memory, length: previousKey.length)
1356-
resultStatement.bind(2, data: updatedKey.memory, length: updatedKey.length)
1357-
case .int64:
1358-
resultStatement.bind(1, number: previousKey.getInt64(0))
1359-
resultStatement.bind(2, number: updatedKey.getInt64(0))
1360-
}
1361-
1362-
return resultStatement
1363-
}
1364-
13651332
private func copyStatement(fromTable: ValueBoxTable, fromKey: ValueBoxKey, toTable: ValueBoxTable, toKey: ValueBoxKey) -> SqlitePreparedStatement {
13661333
precondition(self.queue.isCurrent())
13671334
let _ = checkTable(fromTable)
@@ -1443,6 +1410,8 @@ public final class SqliteValueBox: ValueBox {
14431410
}
14441411

14451412
private func fullTextDeleteStatement(_ table: ValueBoxFullTextTable, itemId: Data) -> SqlitePreparedStatement {
1413+
precondition(self.queue.isCurrent())
1414+
14461415
let resultStatement: SqlitePreparedStatement
14471416

14481417
if let statement = self.fullTextDeleteStatements[table.id] {
@@ -2004,16 +1973,6 @@ public final class SqliteValueBox: ValueBox {
20041973
}
20051974
}
20061975

2007-
public func move(_ table: ValueBoxTable, from previousKey: ValueBoxKey, to updatedKey: ValueBoxKey) {
2008-
precondition(self.queue.isCurrent())
2009-
if let _ = self.tables[table.id] {
2010-
let statement = self.moveStatement(table, from: previousKey, to: updatedKey)
2011-
while statement.step(handle: self.database.handle, pathToRemoveOnError: self.removeDatabaseOnError ? self.databasePath : nil) {
2012-
}
2013-
statement.reset()
2014-
}
2015-
}
2016-
20171976
public func copy(fromTable: ValueBoxTable, fromKey: ValueBoxKey, toTable: ValueBoxTable, toKey: ValueBoxKey) {
20181977
precondition(self.queue.isCurrent())
20191978
if let _ = self.tables[fromTable.id] {
@@ -2254,11 +2213,6 @@ public final class SqliteValueBox: ValueBox {
22542213
}
22552214
self.deleteStatements.removeAll()
22562215

2257-
for (_, statement) in self.moveStatements {
2258-
statement.destroy()
2259-
}
2260-
self.moveStatements.removeAll()
2261-
22622216
for (_, statement) in self.copyStatements {
22632217
statement.destroy()
22642218
}
@@ -2319,7 +2273,7 @@ public final class SqliteValueBox: ValueBox {
23192273

23202274
postboxLog("dropping DB")
23212275

2322-
for fileName in dabaseFileNames {
2276+
for fileName in databaseFileNames {
23232277
let _ = try? FileManager.default.removeItem(atPath: self.basePath + "/\(fileName)")
23242278
}
23252279

@@ -2368,7 +2322,7 @@ public final class SqliteValueBox: ValueBox {
23682322

23692323
self.exportEncrypted(database: database, to: targetPath, encryptionParameters: encryptionParameters)
23702324

2371-
for name in dabaseFileNames {
2325+
for name in databaseFileNames {
23722326
let _ = try? FileManager.default.removeItem(atPath: self.basePath + "/\(name)")
23732327
let _ = try? FileManager.default.moveItem(atPath: targetPath + "/\(name)", toPath: self.basePath + "/\(name)")
23742328
}

submodules/Postbox/Sources/ValueBox.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public protocol ValueBox {
8585
func exists(_ table: ValueBoxTable, key: ValueBoxKey) -> Bool
8686
func set(_ table: ValueBoxTable, key: ValueBoxKey, value: MemoryBuffer)
8787
func remove(_ table: ValueBoxTable, key: ValueBoxKey, secure: Bool)
88-
func move(_ table: ValueBoxTable, from previousKey: ValueBoxKey, to updatedKey: ValueBoxKey)
8988
func copy(fromTable: ValueBoxTable, fromKey: ValueBoxKey, toTable: ValueBoxTable, toKey: ValueBoxKey)
9089
func removeRange(_ table: ValueBoxTable, start: ValueBoxKey, end: ValueBoxKey)
9190
func fullTextSet(_ table: ValueBoxFullTextTable, collectionId: String, itemId: String, contents: String, tags: String)

0 commit comments

Comments
 (0)