Skip to content

Commit

Permalink
0.3.10 Improved embeds in comms
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectricS01 committed Oct 16, 2024
1 parent be49e29 commit ef22762
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 78 deletions.
36 changes: 1 addition & 35 deletions PrivateUploaderAPI/Sources/Fragments/StandardEmbed.graphql.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public struct StandardEmbed: PrivateUploaderAPI.SelectionSet, Fragment {
public static var fragmentDefinition: StaticString {
#"fragment StandardEmbed on EmbedDataV2 { __typename media { __typename url proxyUrl attachment width height isInternal videoEmbedUrl upload { __typename id createdAt attachment userId name type fileSize } mimeType type } text { __typename imageProxyUrl text heading imageUrl } }"#
#"fragment StandardEmbed on EmbedDataV2 { __typename media { __typename url proxyUrl attachment isInternal videoEmbedUrl mimeType type } text { __typename imageProxyUrl text heading imageUrl } }"#
}

public let __data: DataDict
Expand Down Expand Up @@ -34,54 +34,20 @@ public struct StandardEmbed: PrivateUploaderAPI.SelectionSet, Fragment {
.field("url", String?.self),
.field("proxyUrl", String?.self),
.field("attachment", String?.self),
.field("width", Int?.self),
.field("height", Int?.self),
.field("isInternal", Bool.self),
.field("videoEmbedUrl", String?.self),
.field("upload", Upload?.self),
.field("mimeType", String?.self),
.field("type", GraphQLEnum<PrivateUploaderAPI.EmbedMediaType>.self),
] }

public var url: String? { __data["url"] }
public var proxyUrl: String? { __data["proxyUrl"] }
public var attachment: String? { __data["attachment"] }
public var width: Int? { __data["width"] }
public var height: Int? { __data["height"] }
public var isInternal: Bool { __data["isInternal"] }
/// Used for trusted video embed sources, such as YouTube.
public var videoEmbedUrl: String? { __data["videoEmbedUrl"] }
public var upload: Upload? { __data["upload"] }
public var mimeType: String? { __data["mimeType"] }
public var type: GraphQLEnum<PrivateUploaderAPI.EmbedMediaType> { __data["type"] }

/// Medium.Upload
///
/// Parent Type: `Upload`
public struct Upload: PrivateUploaderAPI.SelectionSet {
public let __data: DataDict
public init(_dataDict: DataDict) { __data = _dataDict }

public static var __parentType: ApolloAPI.ParentType { PrivateUploaderAPI.Objects.Upload }
public static var __selections: [ApolloAPI.Selection] { [
.field("__typename", String.self),
.field("id", Int.self),
.field("createdAt", PrivateUploaderAPI.Date.self),
.field("attachment", String.self),
.field("userId", Int.self),
.field("name", String?.self),
.field("type", String.self),
.field("fileSize", Double.self),
] }

public var id: Int { __data["id"] }
public var createdAt: PrivateUploaderAPI.Date { __data["createdAt"] }
public var attachment: String { __data["attachment"] }
public var userId: Int { __data["userId"] }
public var name: String? { __data["name"] }
public var type: String { __data["type"] }
public var fileSize: Double { __data["fileSize"] }
}
}

/// Text
Expand Down
8 changes: 4 additions & 4 deletions TPU_Mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@
CODE_SIGN_ENTITLEMENTS = TPU_Mac/TPU_Mac.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"TPU_Mac/Preview Content\"";
DEVELOPMENT_TEAM = PK36GR28A7;
Expand All @@ -522,7 +522,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.9;
MARKETING_VERSION = 0.3.10;
PRODUCT_BUNDLE_IDENTIFIER = "ElectricS01.TPU-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand All @@ -540,7 +540,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = TPU_Mac/TPU_Mac.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"TPU_Mac/Preview Content\"";
DEVELOPMENT_TEAM = PK36GR28A7;
Expand All @@ -565,7 +565,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.9;
MARKETING_VERSION = 0.3.10;
PRODUCT_BUNDLE_IDENTIFIER = "ElectricS01.TPU-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down
64 changes: 38 additions & 26 deletions TPU_Mac/CommsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,35 +358,47 @@ struct CommsView: View {
.textFieldStyle(RoundedBorderTextFieldStyle())
}
ForEach(message.embeds, id: \.self) { embed in
if let media = embed.media, embed.media != [] {
ForEach(media, id: \.self) { img in
if img.mimeType != "image/gif" {
LazyImage(url: URL(string: img.attachment == nil ? ("https://i.electrics01.com" + (img.proxyUrl ?? "")) : ("https://i.electrics01.com/i/" + (img.attachment ?? "")))) { state in
if let image = state.image {
image.resizable().aspectRatio(contentMode: .fit)
// .onAppear {
//// if chatMessages.count != 0 {
//// proxy.scrollTo(0, anchor: .bottom)
//// }
// }
} else if state.error != nil {
Color.red
} else {
ProgressView()
}
VStack {
if let text = embed.text, embed.text != [] {
ForEach(Array(text.enumerated()), id: \.element) { index, line in
if index == 0 {
Text(line.text ?? "").font( .title2).lineLimit(1 : nil)
} else {
Text(line.text ?? "")
}
} else {
HStack {
WebImage(url: URL(string: img.attachment == nil ? ("https://i.electrics01.com" + (img.proxyUrl ?? "")) : ("https://i.electrics01.com/i/" + (img.attachment ?? "")))) { image in
image.resizable().aspectRatio(contentMode: .fit)
} placeholder: {
ProgressView()
}
}
if let media = embed.media, embed.media != [] {
ForEach(media, id: \.self) { img in
if img.mimeType != "image/gif" {
LazyImage(url: URL(string: img.attachment == nil ? ("https://i.electrics01.com" + (img.proxyUrl ?? "")) : ("https://i.electrics01.com/i/" + (img.attachment ?? "")))) { state in
if let image = state.image {
image.resizable().aspectRatio(contentMode: .fit)
// .onAppear {
//// if chatMessages.count != 0 {
//// proxy.scrollTo(0, anchor: .bottom)
//// }
// }
} else if state.error != nil {
Color.red
} else {
ProgressView()
}
}
} else {
HStack {
WebImage(url: URL(string: img.attachment == nil ? ("https://i.electrics01.com" + (img.proxyUrl ?? "")) : ("https://i.electrics01.com/i/" + (img.attachment ?? "")))) { image in
image.resizable().aspectRatio(contentMode: .fit)
} placeholder: {
ProgressView()
}
}
}
}
}.frame(minWidth: 0, maxWidth: 600, minHeight: 0, maxHeight: 400)
}
}.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .topLeading)
}.frame(minWidth: 0, maxWidth: 600, minHeight: 0, maxHeight: 400).clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}
}.padding(8)
}.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .topLeading).background()
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}
Button(action: {
if replyingId != message.id {
Expand Down
4 changes: 2 additions & 2 deletions TPU_Mac/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ struct SettingsView: View {
Text("Coming soon")
#else
Text("TPU iOS").font(.system(size: 32, weight: .semibold))
Text("Version " + (Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String ?? "") + " (15/10/2024)")
Text("Version " + (Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String ?? "") + " (16/10/2024)")
Text("Made by ElectricS01")
Text("[Give it a Star on GitHub](https://github.com/ElectricS01/TPU-Mac)")
#endif
Expand All @@ -272,7 +272,7 @@ struct AboutView: View {
Text("About")
.navigationTitle("About")
Text("TPU Mac").font(.system(size: 32, weight: .semibold))
Text("Version " + (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "") + " (15/10/2024)")
Text("Version " + (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "") + " (16/10/2024)")
Text("Made by ElectricS01")
Text("[Give it a Star on GitHub](https://github.com/ElectricS01/TPU-Mac)")
}
Expand Down
11 changes: 0 additions & 11 deletions graphql/Comms/MessagesQuery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,8 @@ fragment StandardEmbed on EmbedDataV2 {
url
proxyUrl
attachment
width
height
isInternal
videoEmbedUrl
upload {
id
createdAt
attachment
userId
name
type
fileSize
}
mimeType
type
}
Expand Down

0 comments on commit ef22762

Please sign in to comment.