Periphery cleanup (#5893)

This commit is contained in:
Mauro
2026-07-20 11:16:11 +02:00
committed by GitHub
parent 175aca596e
commit 9093631f8b
275 changed files with 381 additions and 2268 deletions
@@ -72,7 +72,7 @@ final class CompletionSuggestionService: CompletionSuggestionServiceProtocol {
// MARK: - Private
private func updateRoomInfo(_ roomInfo: RoomInfoProxyProtocol) {
if let powerLevels = roomProxy.infoPublisher.value.powerLevels {
if let powerLevels = roomInfo.powerLevels {
canMentionAllUsers = powerLevels.canOwnUserTriggerRoomNotification()
}
}
@@ -75,8 +75,6 @@ struct ComposerToolbarViewState: BindableState {
/// Could be false if sending is disabled in the room
var canSend = true
var suggestions: [SuggestionItem] = []
var audioPlayerState: AudioPlayerState
var audioRecorderState: AudioRecorderState
var isRoomEncrypted: Bool
var isLocationSharingEnabled: Bool
@@ -35,7 +35,6 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
}
private struct WysiwygLinkData {
let action: LinkAction
let range: NSRange
var url: String
var text: String
@@ -65,8 +64,6 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
attributedStringBuilder = AttributedStringBuilder(cacheKey: "Composer", mentionBuilder: mentionBuilder)
super.init(initialViewState: ComposerToolbarViewState(wysiwygViewModel: wysiwygViewModel,
audioPlayerState: .init(id: .recorderPreview, title: L10n.commonVoiceMessage, duration: 0),
audioRecorderState: .init(),
isRoomEncrypted: roomProxy.infoPublisher.value.isEncrypted,
isLocationSharingEnabled: appSettings.mapTilerSettings.publisher.value.isEnabled,
bindings: .init()),
@@ -580,10 +577,8 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
switch mode {
case .default:
break
case .recordVoiceMessage(let audioRecorderState):
state.audioRecorderState = audioRecorderState
case .previewVoiceMessage(let audioPlayerState, _, _):
state.audioPlayerState = audioPlayerState
case .recordVoiceMessage, .previewVoiceMessage:
break
case .edit, .reply:
// Focus composer when switching to reply/edit
state.bindings.composerFocused = true
@@ -645,8 +640,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
private func createLinkAlert() {
let linkAction = wysiwygViewModel.getLinkAction()
currentLinkData = WysiwygLinkData(action: linkAction,
range: wysiwygViewModel.attributedContent.selection,
currentLinkData = WysiwygLinkData(range: wysiwygViewModel.attributedContent.selection,
url: linkAction.url ?? "",
text: "")
@@ -9,7 +9,6 @@
import Combine
import WysiwygComposer
// periphery: ignore - markdown protocol
protocol ComposerToolbarViewModelProtocol {
var actions: AnyPublisher<ComposerToolbarViewModelAction, Never> { get }
var context: ComposerToolbarViewModelType.Context { get }
@@ -33,7 +33,6 @@ struct MessageComposer: View {
let onAppearAction: () -> Void
@State private var composerTranslation: CGFloat = 0
private let composerShape = RoundedRectangle(cornerRadius: 21, style: .circular)
var body: some View {
VStack(spacing: 0) {
@@ -151,7 +151,6 @@ private struct UITextViewWrapper: UIViewRepresentable {
func makeCoordinator() -> Coordinator {
Coordinator(text: $text,
selectedRange: $selectedRange,
maxHeight: maxHeight,
keyHandler: keyHandler,
pasteHandler: pasteHandler)
}
@@ -160,19 +159,15 @@ private struct UITextViewWrapper: UIViewRepresentable {
private var text: Binding<NSAttributedString>
private var selectedRange: Binding<NSRange>
private let maxHeight: CGFloat
private let keyHandler: GenericKeyHandler
private let pasteHandler: PasteHandler
init(text: Binding<NSAttributedString>,
selectedRange: Binding<NSRange>,
maxHeight: CGFloat,
keyHandler: @escaping GenericKeyHandler,
pasteHandler: @escaping PasteHandler) {
self.text = text
self.selectedRange = selectedRange
self.maxHeight = maxHeight
self.keyHandler = keyHandler
self.pasteHandler = pasteHandler
}
@@ -211,7 +206,6 @@ private protocol ElementTextViewDelegate: AnyObject {
private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
private(set) var timelineContext: TimelineViewModel.Context?
private var presendCallback: Binding<(() -> Void)?>
private var pillViews = NSHashTable<UIView>.weakObjects()
weak var elementDelegate: ElementTextViewDelegate?
@@ -219,7 +213,6 @@ private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
init(timelineContext: TimelineViewModel.Context?,
presendCallback: Binding<(() -> Void)?>) {
self.timelineContext = timelineContext
self.presendCallback = presendCallback
super.init(frame: .zero, textContainer: nil)
@@ -241,10 +234,12 @@ private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
UIKeyCommand(input: "\r", modifierFlags: [], action: #selector(enterKeyPressed))]
}
// periphery:ignore:parameters sender - required for objc selector
@objc func shiftEnterKeyPressed(sender: UIKeyCommand) {
elementDelegate?.textViewDidReceiveShiftEnterKeyPress(self)
}
// periphery:ignore:parameters sender - required for objc selector
@objc func enterKeyPressed(sender: UIKeyCommand) {
elementDelegate?.textViewDidReceiveKeyPress(self, key: .keyboardReturnOrEnter)
}
@@ -318,14 +313,6 @@ private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
pillViews.add(pillView)
}
func flushPills() {
for view in pillViews.allObjects {
view.alpha = 0.0
view.removeFromSuperview()
}
pillViews.removeAllObjects()
}
// MARK: - Private
private func acceptCurrentSuggestion() {