Added edit history

This commit is contained in:
Thomas Ricouard 2023-01-19 21:19:19 +01:00
parent cbd4b7acef
commit e05734fe1a
10 changed files with 116 additions and 12 deletions

View file

@ -613,7 +613,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp.IceCubesNotifications;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
@ -643,7 +643,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp.IceCubesNotifications;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
@ -674,7 +674,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp.IceCubesShareExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
@ -704,7 +704,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp.IceCubesShareExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
@ -866,7 +866,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
@ -918,7 +918,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;

View file

@ -66,6 +66,9 @@ extension View {
case .addRemoteLocalTimeline:
AddRemoteTimelineView()
.withEnvironments()
case let .statusEditHistory(status):
StatusEditHistoryView(statusId: status)
.withEnvironments()
}
}
}

View file

@ -299,6 +299,7 @@
"status.show-less" = "Show less";
"status.show-more" = "Show more";
"status.summary.at-time" = " at ";
"status.summary.edited-time" = "Last edited: ";
"status.summary.n-boosts %lld" = "%lld boosts";
"status.summary.n-favorites %lld" = "%lld favorites";
"status.visibility.direct" = "Private";

View file

@ -4,8 +4,6 @@
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ShareViewController</string>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
@ -22,6 +20,8 @@
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ShareViewController</string>
</dict>
</dict>
</plist>

View file

@ -26,6 +26,7 @@ public enum SheetDestinations: Identifiable {
case listAddAccount(account: Account)
case addAccount
case addRemoteLocalTimeline
case statusEditHistory(status: String)
public var id: String {
switch self {
@ -39,6 +40,8 @@ public enum SheetDestinations: Identifiable {
return "addAccount"
case .addRemoteLocalTimeline:
return "addRemoteLocalTimeline"
case .statusEditHistory:
return "statusEditHistory"
}
}
}

View file

@ -0,0 +1,11 @@
import Foundation
public struct StatusHistory: Decodable, Identifiable {
public var id: String {
createdAt.description
}
public let content: HTMLString
public let createdAt: ServerDate
public let emojis: [Emoji]
}

View file

@ -16,6 +16,7 @@ public enum Statuses: Endpoint {
case unpin(id: String)
case bookmark(id: String)
case unbookmark(id: String)
case history(id: String)
public func path() -> String {
switch self {
@ -47,6 +48,8 @@ public enum Statuses: Endpoint {
return "statuses/\(id)/bookmark"
case let .unbookmark(id):
return "statuses/\(id)/unbookmark"
case let .history(id):
return "statuses/\(id)/history"
}
}

View file

@ -110,7 +110,7 @@ class NotificationsViewModel: ObservableObject {
{
if let selectedType, event.notification.type == selectedType.rawValue {
notifications.insert(event.notification, at: 0)
} else {
} else if selectedType == nil {
notifications.insert(event.notification, at: 0)
}
state = .display(notifications: notifications, nextPageState: .hasNextPage)

View file

@ -0,0 +1,66 @@
import SwiftUI
import Models
import Network
import DesignSystem
public struct StatusEditHistoryView: View {
@Environment(\.dismiss) private var dismiss
@EnvironmentObject private var client: Client
@EnvironmentObject private var theme: Theme
private let statusId: String
@State private var history: [StatusHistory]?
public init(statusId: String) {
self.statusId = statusId
}
public var body: some View {
NavigationStack {
List {
Section {
if let history {
ForEach(history) { edit in
VStack(alignment: .leading, spacing: 8){
EmojiTextApp(edit.content.asMarkdown, emojis: edit.emojis)
.font(.scaledBody)
Group {
Text(edit.createdAt.asDate, style: .date) +
Text("status.summary.at-time") +
Text(edit.createdAt.asDate, style: .time)
}
.font(.footnote)
.foregroundColor(.gray)
}
}
} else {
HStack {
Spacer()
ProgressView()
Spacer()
}
}
}.listRowBackground(theme.primaryBackgroundColor)
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button("action.done", action: { dismiss() })
}
}
.navigationTitle("Edit History")
.navigationBarTitleDisplayMode(.inline)
.task {
do {
history = try await client.get(endpoint: Statuses.history(id: statusId))
} catch {
print(error)
}
}
.listStyle(.plain)
.scrollContentBackground(.hidden)
.background(theme.primaryBackgroundColor)
}
}
}

View file

@ -117,6 +117,23 @@ struct StatusActionsView: View {
.font(.scaledCaption)
.foregroundColor(.gray)
if let editedAt = viewModel.status.editedAt {
Divider()
HStack {
Text("status.summary.edited-time") +
Text(editedAt.asDate, style: .date) +
Text("status.summary.at-time") +
Text(editedAt.asDate, style: .time)
Spacer()
}
.onTapGesture {
routerPath.presentedSheet = .statusEditHistory(status: viewModel.status.id)
}
.underline()
.font(.scaledCaption)
.foregroundColor(.gray)
}
if viewModel.favouritesCount > 0 {
Divider()
NavigationLink(value: RouterDestinations.favouritedBy(id: viewModel.status.id)) {