Skip to content

Commit

Permalink
feat(iosApp): use new social API for event and speakers.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Dec 9, 2024
1 parent 1b7d2e2 commit 414f3ac
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
Binary file not shown.
47 changes: 43 additions & 4 deletions iosApp/iosApp/screens/event/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ struct Event: View {
@State var showScanner = false
@Environment(\.openURL) var openURL
let event: EventUi
let linkedin: String?
let x: String?
let mastodon: String?
let bluesky: String?
let facebook: String?
let instagram: String?
let youtube: String?
let github: String?
let website: String?
let barcodeScanned: (String) async -> ()
let onDisconnectedClicked: () -> ()

Expand All @@ -23,6 +32,15 @@ struct Event: View {
onDisconnectedClicked: @escaping () -> ()
) {
self.event = event
self.linkedin = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.linkedin })?.url
self.x = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.x })?.url
self.mastodon = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.mastodon })?.url
self.bluesky = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.bluesky })?.url
self.facebook = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.facebook })?.url
self.instagram = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.instagram })?.url
self.youtube = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.youtube })?.url
self.github = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.github })?.url
self.website = event.eventInfo.socials.first(where: { $0.type == SocialTypeUi.website })?.url
self.barcodeScanned = barcodeScanned
self.onDisconnectedClicked = onDisconnectedClicked
}
Expand Down Expand Up @@ -63,11 +81,32 @@ struct Event: View {
Section(header: Text("titleLinks")) {
Link("actionFaq", destination: URL(string: event.eventInfo.faqLink)!)
Link("actionCoc", destination: URL(string: event.eventInfo.codeOfConductLink)!)
if (event.eventInfo.twitterUrl != nil) {
Link("actionX", destination: URL(string: event.eventInfo.twitterUrl!)!)
if (self.linkedin != nil) {
Link("actionLinkedin", destination: URL(string: self.linkedin!)!)
}
if (event.eventInfo.linkedinUrl != nil) {
Link("actionLinkedin", destination: URL(string: event.eventInfo.linkedinUrl!)!)
if (self.x != nil) {
Link("actionX", destination: URL(string: self.x!)!)
}
if (self.mastodon != nil) {
Link("actionMastodon", destination: URL(string: self.mastodon!)!)
}
if (self.bluesky != nil) {
Link("actionBluesky", destination: URL(string: self.bluesky!)!)
}
if (self.facebook != nil) {
Link("actionFacebook", destination: URL(string: self.facebook!)!)
}
if (self.instagram != nil) {
Link("actionInstagram", destination: URL(string: self.instagram!)!)
}
if (self.youtube != nil) {
Link("actionYouTube", destination: URL(string: self.youtube!)!)
}
if (self.github != nil) {
Link("actionGitHub", destination: URL(string: self.github!)!)
}
if (self.website != nil) {
Link("actionWebsite", destination: URL(string: self.website!)!)
}
}
Section {
Expand Down
14 changes: 9 additions & 5 deletions iosApp/iosApp/screens/speaker/SpeakerDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ struct SpeakerDetail: View {
title: speaker.name,
pronouns: speaker.pronouns,
logoUrl: speaker.url,
xUrl: speaker.twitterUrl,
mastodonUrl: speaker.mastodonUrl,
linkedInUrl: speaker.linkedinUrl,
githubUrl: speaker.githubUrl,
websiteUrl: speaker.websiteUrl
xUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.x })?.url,
mastodonUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.mastodon })?.url,
blueskyUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.bluesky })?.url,
facebookUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.facebook })?.url,
instagramUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.instagram })?.url,
youtubeUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.youtube })?.url,
linkedInUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.linkedin })?.url,
websiteUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.website })?.url,
emailUrl: speaker.socials.first(where: { $0.type == SocialTypeUi.email })?.url
)
Spacer()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ internal class EventRepositoryImpl(

override suspend fun fetchAndStoreAgenda() {
val eventId = settings.getEventId()
val event = api.fetchEvent(eventId)
val qanda = api.fetchQAndA(eventId)
val partners = api.fetchPartnersActivities(eventId)
eventDao.insertEvent(event, qanda)
partnerDao.insertPartners(eventId, partners)
val etag = settings.lastEtag(eventId)
try {
val (newEtag, agenda) = api.fetchAgenda(eventId, etag)
Expand All @@ -49,11 +54,6 @@ internal class EventRepositoryImpl(
} catch (ex: AgendaNotModifiedException) {
ex.printStackTrace()
}
val event = api.fetchEvent(eventId)
val qanda = api.fetchQAndA(eventId)
val partners = api.fetchPartnersActivities(eventId)
eventDao.insertEvent(event, qanda)
partnerDao.insertPartners(eventId, partners)
}

override fun events(): Flow<EventItemList> = eventDao.fetchEventList()
Expand Down

0 comments on commit 414f3ac

Please sign in to comment.