Skip to content

Commit

Permalink
1.7.8 (305)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Aug 30, 2024
1 parent 5f29b16 commit e114b03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 142 deletions.
144 changes: 7 additions & 137 deletions submodules/ChatListUI/Sources/ChatListController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -360,78 +360,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
)
}
//
// MARK: Nicegram waiting network bug
if #available(iOS 15.0, *) {
self.primaryContext?.restartMTProtoButton = AnyComponentWithIdentity(
id: "restartMTProto",
component: AnyComponent(NavigationButtonComponent(
content: .text(title: "R1", isBold: true),
pressed: { [weak self] _ in
self?.context.account.network.restartProto()
}
)))

self.primaryContext?.resetMTProtoButton = AnyComponentWithIdentity(
id: "resetMTProto",
component: AnyComponent(NavigationButtonComponent(
content: .text(title: "R2", isBold: true),
pressed: { [weak self] _ in
self?.context.account.network.resetProto()
}
)))

self.primaryContext?.sendMessageToSavedButton = AnyComponentWithIdentity(
id: "sendMessageToSaved",
component: AnyComponent(NavigationButtonComponent(
content: .text(title: "SM", isBold: true),
pressed: { [weak self] _ in
guard let self else { return }

let peerId = self.context.account.peerId
let messageId = MessageId(peerId: peerId, namespace: 0, id: 666666)

let message = StoreMessage(
id: messageId,
globallyUniqueId: nil,
groupingKey: nil,
threadId: nil,
timestamp: 1,
flags: .init(),
tags: .init(),
globalTags: .init(),
localTags: .init(),
forwardInfo: nil,
authorId: .init(namespace: peerId.namespace, id: peerId.id),
text: ":)",
attributes: [],
media: []
)

_ = (self.context.account.postbox.transaction { transaction in
transaction.addMessages([message], location: .Random)
}).start(next: { [weak self] _ in
guard let self else { return }

_ = (self.context.account.postbox.transaction { transaction in
transaction.deleteMessages(
[messageId],
forEachMedia: nil
)
}).start()
})
}
)))

self.primaryContext?.simulateDisconnectionButton = AnyComponentWithIdentity(
id: "simulateDisconnection",
component: AnyComponent(NavigationButtonComponent(
content: .text(title: "SD", isBold: true),
pressed: { [weak self] _ in
self?.context.account.network.simulateDisconnection()
}
)))
}
//

//let backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.DialogList_Title, style: .plain, target: nil, action: nil)
//backBarButtonItem.accessibilityLabel = self.presentationData.strings.Common_Back
Expand Down Expand Up @@ -6383,13 +6311,6 @@ private final class ChatListLocationContext {
// MARK: Nicegram Assistant
var nicegramButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
//
// MARK: Nicegram waiting network bug
var restartMTProtoButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var resetMTProtoButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var sendMessageToSavedButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var simulateDisconnectionButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
//

var leftButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var rightButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var proxyButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
Expand All @@ -6410,21 +6331,7 @@ private final class ChatListLocationContext {
if let nicegramButton = self.nicegramButton {
result.append(nicegramButton)
}
//
// MARK: Nicegram waiting network bug
if let restartMTProtoButton {
result.append(restartMTProtoButton)
}
if let resetMTProtoButton {
result.append(resetMTProtoButton)
}
if let sendMessageToSavedButton {
result.append(sendMessageToSavedButton)
}
if let simulateDisconnectionButton {
result.append(simulateDisconnectionButton)
}
//

return result
}

Expand Down Expand Up @@ -6818,9 +6725,6 @@ private final class ChatListLocationContext {
switch networkState {
case .waitingForNetwork:
titleContent = NetworkStatusTitle(text: presentationData.strings.State_WaitingForNetwork, activity: true, hasProxy: false, connectsViaProxy: connectsViaProxy, isPasscodeSet: false, isManuallyLocked: false, peerStatus: peerStatus)
// MARK: Nicegram waiting network bug
self.addAndDeleteSavedMessage(with: networkState)
//
case let .connecting(proxy):
let text = presentationData.strings.State_Connecting
let _ = proxy
Expand Down Expand Up @@ -6916,9 +6820,6 @@ private final class ChatListLocationContext {
switch networkState {
case .waitingForNetwork:
titleContent = NetworkStatusTitle(text: presentationData.strings.State_WaitingForNetwork, activity: true, hasProxy: false, connectsViaProxy: connectsViaProxy, isPasscodeSet: isRoot && isPasscodeSet, isManuallyLocked: isRoot && isManuallyLocked, peerStatus: peerStatus)
// MARK: Nicegram waiting network bug
self.addAndDeleteSavedMessage(with: networkState)
//
case let .connecting(proxy):
let text = presentationData.strings.State_Connecting
/*if let layout = strongSelf.validLayout, proxy != nil && layout.metrics.widthClass != .regular && layout.size.width > 320.0 {*/
Expand Down Expand Up @@ -6999,6 +6900,12 @@ private final class ChatListLocationContext {
}
self.parentController?.maybeDisplayStoryTooltip()
})

// MARK: Nicegram waiting network bug
if case .waitingForNetwork = networkState {
context.account.network.restartProto()
}
//
}

private func updateForum(
Expand Down Expand Up @@ -7109,41 +7016,4 @@ private final class ChatListLocationContext {
break
}
}

// MARK: Nicegram waiting network bug
private func addAndDeleteSavedMessage(with networkState: AccountNetworkState) {
let peerId = self.context.account.peerId
let messageId = MessageId(peerId: peerId, namespace: 0, id: 666666)

let message = StoreMessage(
id: messageId,
globallyUniqueId: nil,
groupingKey: nil,
threadId: nil,
timestamp: 1,
flags: .init(),
tags: .init(),
globalTags: .init(),
localTags: .init(),
forwardInfo: nil,
authorId: .init(namespace: peerId.namespace, id: peerId.id),
text: ":)",
attributes: [],
media: []
)

_ = (self.context.account.postbox.transaction { transaction in
transaction.addMessages([message], location: .Random)
}).start(next: { [weak self] _ in
guard let self else { return }

_ = (self.context.account.postbox.transaction { transaction in
transaction.deleteMessages(
[messageId],
forEachMedia: nil
)
}).start()
})
}
//
}
5 changes: 0 additions & 5 deletions submodules/TelegramCore/Sources/Network/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,6 @@ public final class Network: NSObject, MTRequestMessageServiceDelegate {
mtProto.simulateDisconnection()
mtProto.resume()
}

public func resetProto() {
mtProto.requestSecureTransportReset()
mtProto.requestTransportTransaction()
}
//
}

Expand Down

0 comments on commit e114b03

Please sign in to comment.