Use shared deck card in case there is no reference data available

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
This commit is contained in:
Marcel Müller 2022-11-09 17:30:30 +01:00
Родитель 481472c427
Коммит 44abdd3bb3
4 изменённых файлов: 38 добавлений и 2 удалений

Просмотреть файл

@ -380,7 +380,15 @@
}
[message getReferenceDataWithCompletionBlock:^(NCChatMessage *message, NSDictionary *referenceData, NSString *url) {
if ([self.message isSameMessage:message]) {
if (![self.message isSameMessage:message]) {
return;
}
if (!referenceData && message.deckCard) {
// In case we were unable to retrieve reference data (for example if the user has no permissions)
// but the message is a shared deck card, we use the shared information to show the deck view
[self.referenceView updateFor:message.deckCard];
} else {
[self.referenceView updateFor:referenceData and:url];
}
}];

Просмотреть файл

@ -134,7 +134,15 @@
_vConstraint[3].constant = 100;
[message getReferenceDataWithCompletionBlock:^(NCChatMessage *message, NSDictionary *referenceData, NSString *url) {
if ([self.message isSameMessage:message]) {
if (![self.message isSameMessage:message]) {
return;
}
if (!referenceData && message.deckCard) {
// In case we were unable to retrieve reference data (for example if the user has no permissions)
// but the message is a shared deck card, we use the shared information to show the deck view
[self.referenceView updateFor:message.deckCard];
} else {
[self.referenceView updateFor:referenceData and:url];
}
}];

Просмотреть файл

@ -69,6 +69,16 @@ import Foundation
}
}
func update(for sharedDeckCard: NCDeckCardParameter) {
referenceTypeIcon.image = UIImage(named: "deck-item")
self.url = sharedDeckCard.link
referenceTitle.text = sharedDeckCard.name ?? ""
referenceDescription.isHidden = true
referenceDueDate.isHidden = true
referenceDueDateIcon.isHidden = true
}
func update(for reference: [String: AnyObject], and url: String) {
self.url = url

Просмотреть файл

@ -81,6 +81,16 @@
referenceView.addSubview(defaultView)
}
func update(for sharedDeckCard: NCDeckCardParameter) {
let deckView = ReferenceDeckView(frame: self.frame)
deckView.update(for: sharedDeckCard)
deckView.frame = self.bounds
deckView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
referenceView.addSubview(deckView)
self.hideIndicatorView()
}
func update(for references: [String: [String: AnyObject]]?, and url: String) {
referenceView.subviews.forEach({ $0.removeFromSuperview() })