mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-28 14:10:44 +00:00
Display Unsupported alert when theme is unreadable
This commit is contained in:
parent
46ffac9bc6
commit
af8c6c7e57
@ -487,15 +487,22 @@ func openChatTheme(context: AccountContext, message: Message, pushController: @e
|
|||||||
} else if let contentFile = content.file, contentFile.mimeType == mimeType {
|
} else if let contentFile = content.file, contentFile.mimeType == mimeType {
|
||||||
file = contentFile
|
file = contentFile
|
||||||
}
|
}
|
||||||
if case let .theme(slug) = resolvedUrl, let file = file {
|
let displayUnsupportedAlert: () -> Void = {
|
||||||
if let path = context.sharedContext.accountManager.mediaBox.completedResourcePath(file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead), let theme = makePresentationTheme(data: data) {
|
|
||||||
let controller = ThemePreviewController(context: context, previewTheme: theme, source: .slug(slug, file))
|
|
||||||
pushController(controller)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
present(textAlertController(context: context, title: nil, text: presentationData.strings.Theme_Unsupported, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
present(textAlertController(context: context, title: nil, text: presentationData.strings.Theme_Unsupported, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||||
}
|
}
|
||||||
|
if case let .theme(slug) = resolvedUrl, let file = file {
|
||||||
|
if let path = context.sharedContext.accountManager.mediaBox.completedResourcePath(file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||||
|
if let theme = makePresentationTheme(data: data) {
|
||||||
|
let controller = ThemePreviewController(context: context, previewTheme: theme, source: .slug(slug, file))
|
||||||
|
pushController(controller)
|
||||||
|
} else {
|
||||||
|
displayUnsupportedAlert()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
displayUnsupportedAlert()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user