mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-05 18:38:54 +00:00
* implements auto cache cleanup when zero persistence mode is enabled (0 value) * uses memory flag with sqlite instead of loki when running in zero persistence mode * renames ephemeral mode manager and improves readability * zero persistence refactors and restore values during transitions * fixes ephemeral mode tests * use initializeClient instead of just initialize to wait for doReconnect to finish that way teams loading is awaited while WS reconnects during ZPM transitions * adds inital sync as a mount hook to prevent undesired load error states during app cold start in ZPM mode, we need a way to load team and channels without showing loading error during the transition. The nre is initial sync hook allows for it * reset started sync subject on wipe * removes extra log lines * resets tracked server during ephemeral mode transitions * improvements to apply persistence mode changes when something fails * address coderabbit PR suggestions * add batching time logging * throws ephemeral mode change error as is * make deleteServerDatabaseFiles private * inline derive persistence flag function * return current user id when refetching current user * support zero persistence mode server for push notifications * adds support for zero persistence mode when sharing to mattermost * adds clarifying comment * catch and log error deleting files * reorder translations to correct position * adds some new tests to improve coverage * ios push notification native fix * logout when fetchMe fails with 401 status code during reconnection * properly surface errors * return proper false value when checking for zero persistence flag * change comments and properly await on some operations * prevent not set persistence mode to report as an error Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * include servers with no persistence flag set in share list * disable button for accessibility Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * improves when to store and remove signing key from global area * review push notification reception running in zero persistence mode * add server to ephemeral mode manager right after login --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
113 lines
3.5 KiB
Swift
113 lines
3.5 KiB
Swift
//
|
|
// InitialView.swift
|
|
// MattermostShare
|
|
//
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct InitialView: View {
|
|
@EnvironmentObject var shareViewModel: ShareViewModel
|
|
|
|
@Binding var attachments: [AttachmentModel]
|
|
@Binding var linkPreviewUrl: String
|
|
@Binding var message: String
|
|
@State var error: String?
|
|
|
|
let onError = NotificationCenter.default.publisher(for: Notification.Name("errorPosting"))
|
|
|
|
var noServers: Bool {
|
|
shareViewModel.allServers.count == 0
|
|
}
|
|
|
|
var onlyZeroPersistenceServers: Bool {
|
|
!shareViewModel.allServers.isEmpty && shareViewModel.server == nil
|
|
}
|
|
|
|
var noChannels: Bool {
|
|
shareViewModel.allServers.allSatisfy({!$0.hasChannels})
|
|
}
|
|
|
|
init(attachments: Binding<[AttachmentModel]>,
|
|
linkPreviewUrl: Binding<String>,
|
|
message: Binding<String>
|
|
) {
|
|
let appearance = UINavigationBarAppearance()
|
|
appearance.configureWithTransparentBackground()
|
|
|
|
appearance.titleTextAttributes = [.foregroundColor: UIColor(.white), .font: UIFont(name: "Metropolis-SemiBold", size: 18) as Any]
|
|
appearance.backgroundColor = UIColor(Color.theme.sidebarBg)
|
|
UINavigationBar.appearance().standardAppearance = appearance
|
|
UINavigationBar.appearance().scrollEdgeAppearance = appearance
|
|
UINavigationBar.appearance().tintColor = UIColor(Color.theme.sidebarText)
|
|
self._attachments = attachments
|
|
self._linkPreviewUrl = linkPreviewUrl
|
|
self._message = message
|
|
}
|
|
|
|
var body: some View {
|
|
return VStack {
|
|
if error != nil {
|
|
ErrorSharingView(error: error!)
|
|
.transition(.opacity)
|
|
} else if noServers {
|
|
NoServersView()
|
|
} else if onlyZeroPersistenceServers {
|
|
VStack(spacing: 8) {
|
|
Text(NSLocalizedString("extension.zero_persistence_servers.title",
|
|
value: "Sharing unavailable",
|
|
comment: ""
|
|
))
|
|
.font(Font.custom("Metropolis-SemiBold", size: 20))
|
|
.foregroundColor(Color.theme.centerChannelColor)
|
|
Text(NSLocalizedString("extension.zero_persistence_servers.description",
|
|
value: "Sharing is unavailable because this server is configured in zero persistence mode.",
|
|
comment: ""
|
|
))
|
|
.font(Font.custom("OpenSans", size: 16))
|
|
.foregroundColor(Color.theme.centerChannelColor.opacity(0.72))
|
|
.multilineTextAlignment(.center)
|
|
}
|
|
.padding(.horizontal, 12)
|
|
} else if noChannels {
|
|
NoMembershipView()
|
|
} else {
|
|
ContentView(
|
|
attachments: $attachments,
|
|
linkPreviewUrl: $linkPreviewUrl,
|
|
message: $message
|
|
)
|
|
}
|
|
}
|
|
.accentColor(.white)
|
|
.navigationBarTitle(
|
|
NSLocalizedString("share_extension.share_screen.title",
|
|
value: "Share to {applicationName}",
|
|
comment: ""
|
|
)
|
|
.replacingOccurrences(
|
|
of: "{applicationName}",
|
|
with: Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String ?? "Mattermost Beta"
|
|
),
|
|
displayMode: .inline
|
|
)
|
|
.navigationBarItems(
|
|
leading: CancelButton(attachments: attachments),
|
|
trailing: PostButton(
|
|
attachments: $attachments,
|
|
linkPreviewUrl: linkPreviewUrl,
|
|
message: $message
|
|
)
|
|
)
|
|
.padding(20)
|
|
.animation(.linear(duration: 0.3))
|
|
.onReceive(onError) {obj in
|
|
if let userInfo = obj.userInfo, let info = userInfo["info"] as? String {
|
|
error = info
|
|
}
|
|
}
|
|
}
|
|
}
|