diff --git a/PrivateUploaderAPI/Sources/Operations/Queries/StateQuery.graphql.swift b/PrivateUploaderAPI/Sources/Operations/Queries/StateQuery.graphql.swift index 8c7fe4c..d8f8fea 100644 --- a/PrivateUploaderAPI/Sources/Operations/Queries/StateQuery.graphql.swift +++ b/PrivateUploaderAPI/Sources/Operations/Queries/StateQuery.graphql.swift @@ -7,7 +7,7 @@ public class StateQuery: GraphQLQuery { public static let operationName: String = "StateQuery" public static let operationDocument: ApolloAPI.OperationDocument = .init( definition: .init( - #"query StateQuery { coreState { __typename announcements { __typename userId content type id createdAt user { __typename username id avatar } } stats { __typename users collections collectionItems uploads messages chats } } currentUser { __typename username description administrator emailVerified banned createdAt avatar moderator banner status storedStatus privacyPolicyAccepted domain { __typename active domain id } badges { __typename color icon id image name priority tooltip } id notifications { __typename id dismissed message route createdAt } } trackedUsers { __typename username id avatar blocked status bot nickname { __typename nickname } friends { __typename friendId id status userId } } }"# + #"query StateQuery { coreState { __typename announcements { __typename userId content createdAt user { __typename username id avatar } } stats { __typename users collections collectionItems uploads messages chats } } currentUser { __typename username description administrator emailVerified banned createdAt avatar moderator banner status storedStatus privacyPolicyAccepted domain { __typename active domain id } badges { __typename color icon id image name priority tooltip } id notifications { __typename id dismissed message route createdAt } } trackedUsers { __typename username id avatar blocked status bot nickname { __typename nickname } friends { __typename friendId id status userId } } }"# )) public init() {} @@ -56,16 +56,12 @@ public class StateQuery: GraphQLQuery { .field("__typename", String.self), .field("userId", Int?.self), .field("content", String.self), - .field("type", String?.self), - .field("id", Int.self), .field("createdAt", PrivateUploaderAPI.Date?.self), .field("user", User?.self), ] } public var userId: Int? { __data["userId"] } public var content: String { __data["content"] } - public var type: String? { __data["type"] } - public var id: Int { __data["id"] } public var createdAt: PrivateUploaderAPI.Date? { __data["createdAt"] } public var user: User? { __data["user"] } diff --git a/TPU_Mac.xcodeproj/project.pbxproj b/TPU_Mac.xcodeproj/project.pbxproj index 319c0c5..6b58bd0 100644 --- a/TPU_Mac.xcodeproj/project.pbxproj +++ b/TPU_Mac.xcodeproj/project.pbxproj @@ -523,7 +523,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 0.3.13; + MARKETING_VERSION = 0.3.14; PRODUCT_BUNDLE_IDENTIFIER = "ElectricS01.TPU-Mac"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; @@ -566,7 +566,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 0.3.13; + MARKETING_VERSION = 0.3.14; PRODUCT_BUNDLE_IDENTIFIER = "ElectricS01.TPU-Mac"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; diff --git a/TPU_Mac/CommsView.swift b/TPU_Mac/CommsView.swift index b696655..b551dd2 100644 --- a/TPU_Mac/CommsView.swift +++ b/TPU_Mac/CommsView.swift @@ -28,7 +28,6 @@ struct CommsView: View { @State private var editingMessage: String = "" @State var apolloSubscription: Apollo.Cancellable? @State private var notifications: Int = 0 - // @State private var hoverItem = -1 func getChats() { Network.shared.apollo.fetch(query: ChatsQuery(), cachePolicy: .fetchIgnoringCacheData) { result in @@ -43,56 +42,6 @@ struct CommsView: View { } } - func convertToMessage(subscriptionObject: UpdateMessagesSubscription.Data.OnMessage.Message) -> MessagesQuery.Data.Message { - var messageData = DataDict(data: [:], fulfilledFragments: Set()) - - messageData["id"] = subscriptionObject.id - messageData["createdAt"] = subscriptionObject.createdAt - messageData["updatedAt"] = subscriptionObject.updatedAt - messageData["chatId"] = subscriptionObject.chatId - messageData["userId"] = subscriptionObject.userId - messageData["content"] = subscriptionObject.content - messageData["type"] = subscriptionObject.type - messageData["emoji"] = subscriptionObject.emoji - messageData["embeds"] = subscriptionObject.embeds - messageData["reply"] = subscriptionObject.reply - messageData["user"] = subscriptionObject.user - messageData["edited"] = subscriptionObject.edited - messageData["editedAt"] = subscriptionObject.editedAt - messageData["replyId"] = subscriptionObject.replyId - messageData["pinned"] = subscriptionObject.pinned - messageData["readReceipts"] = subscriptionObject.readReceipts - - let message = MessagesQuery.Data.Message(_dataDict: messageData) - - return message - } - - func editToMessage(messageObject: MessagesQuery.Data.Message, editObject: EditedMessageSubscription.Data.OnEditMessage.Message) -> MessagesQuery.Data.Message { - var messageData = DataDict(data: [:], fulfilledFragments: Set()) - - messageData["id"] = editObject.id - messageData["createdAt"] = messageObject.createdAt - messageData["updatedAt"] = messageObject.updatedAt - messageData["chatId"] = messageObject.chatId - messageData["userId"] = editObject.userId - messageData["content"] = editObject.content - messageData["type"] = messageObject.type - messageData["emoji"] = editObject.emoji - messageData["embeds"] = editObject.embeds - messageData["reply"] = messageObject.reply - messageData["user"] = messageObject.user - messageData["edited"] = editObject.edited - messageData["editedAt"] = editObject.editedAt - messageData["replyId"] = messageObject.replyId - messageData["pinned"] = editObject.pinned - messageData["readReceipts"] = messageObject.readReceipts - - let message = MessagesQuery.Data.Message(_dataDict: messageData) - - return message - } - func newToChat(chatObject: ChatsQuery.Data.Chat, self: Bool) -> ChatsQuery.Data.Chat { var chatData = DataDict(data: [:], fulfilledFragments: Set()) diff --git a/TPU_Mac/HomeView.swift b/TPU_Mac/HomeView.swift index 0be4dc8..2d905cb 100644 --- a/TPU_Mac/HomeView.swift +++ b/TPU_Mac/HomeView.swift @@ -6,6 +6,7 @@ // import Apollo +import MarkdownUI import PrivateUploaderAPI import SwiftUI @@ -23,6 +24,27 @@ struct HomeStat: View { } } +struct NewsItem: View { + @Binding var item: StateQuery.Data.CoreState.Announcement + + var body: some View { + ProfilePicture(avatar: item.user?.avatar, size: 48) + Text(item.user?.username ?? "Deleted User").font(.system(size: 16, weight: .semibold)) + Markdown(item.content) + .markdownSoftBreakMode(.lineBreak) + .textSelection(.enabled) + .markdownBlockStyle(\.blockquote) { configuration in + configuration.label + .padding(EdgeInsets(top: 2, leading: 8, bottom: 2, trailing: 2)) + .overlay(alignment: .leading) { + Rectangle().frame(width: 2) + } + } + .multilineTextAlignment(.center) + Text(DateUtils.dateFormat(item.createdAt)) + } +} + struct HomeView: View { @EnvironmentObject var store: Store @@ -37,10 +59,7 @@ struct HomeView: View { Text("Announcments").font(.system(size: 24, weight: .semibold)) ScrollView { ForEach(store.coreState?.announcements ?? [], id: \.self) { item in - ProfilePicture(avatar: item.user?.avatar, size: 48) - Text(item.user?.username ?? "Deleted User").font(.system(size: 16, weight: .semibold)) - Text(item.content).multilineTextAlignment(.center) - Text(DateUtils.dateFormat(item.createdAt)) + NewsItem(item: .constant(item)) }.padding() } }.frame(maxHeight: .infinity) diff --git a/graphql/StateQuery.graphql b/graphql/StateQuery.graphql index cc32674..9fc95ef 100644 --- a/graphql/StateQuery.graphql +++ b/graphql/StateQuery.graphql @@ -3,8 +3,6 @@ query StateQuery { announcements { userId content - type - id createdAt user { username