Skip to content

Commit

Permalink
#74 implemented favorite button on speaker talks
Browse files Browse the repository at this point in the history
  • Loading branch information
fcamblor committed Oct 31, 2024
1 parent ecf0d52 commit eb90111
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 54 deletions.
49 changes: 0 additions & 49 deletions mobile/src/components/speaker-card/SpeakerFavTalkButton.vue

This file was deleted.

27 changes: 24 additions & 3 deletions mobile/src/components/speaker-card/SpeakerTalk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<ion-text>
{{ talk.title }}
</ion-text>
<SpeakerFavTalkButton></SpeakerFavTalkButton>
<talk-favorite-button v-if="talkNotes" :conf-descriptor="confDescriptor"
:user-talk-notes="talkNotes" :talk-stats="talkStats" :local-favorite="localEventTalkNotes"
@talk-note-updated="$emit('talk-note-updated', $event)"
/>
</div>
<div class="talkResumeCard-footer">
<div class="talkResumeCard-footer-left">
Expand Down Expand Up @@ -43,14 +46,15 @@
<script setup lang="ts">
import {typesafeI18n} from "@/i18n/i18n-vue";
import {IonBadge, IonText} from "@ionic/vue";
import SpeakerFavTalkButton from "@/components/speaker-card/SpeakerFavTalkButton.vue";
import {VoxxrinLineupSpeaker, VoxxrinLineupTalk,} from "@/models/VoxxrinSpeaker";
import SpeakerThumbnail from "@/components/speaker/SpeakerThumbnail.vue";
import {PropType} from "vue";
import {VoxxrinConferenceDescriptor} from "@/models/VoxxrinConferenceDescriptor";
import TalkFavoriteButton from "@/components/talk-card/TalkFavoriteButton.vue";
import {TalkStats} from "../../../../shared/event-stats";
import {TalkNote} from "../../../../shared/feedbacks.firestore";
const {LL} = typesafeI18n()
const baseUrl = import.meta.env.BASE_URL;
const props = defineProps({
talk: {
Expand All @@ -65,8 +69,25 @@ const props = defineProps({
required: true,
type: Object as PropType<VoxxrinConferenceDescriptor>
},
talkStats: {
required: true,
type: Object as PropType<TalkStats|undefined>
},
talkNotes: {
required: true,
type: Object as PropType<TalkNote|undefined>
},
localEventTalkNotes: {
required: false,
type: Number as PropType<1 | -1 | undefined>,
default: undefined,
}
})
defineEmits<{
(e: 'talk-note-updated', event: TalkNote): void,
}>()
</script>

<style lang="scss" scoped>
Expand Down
25 changes: 24 additions & 1 deletion mobile/src/views/SpeakerDetailsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@
</div>
<div class="sectionBloc" v-if="speaker.talks.length > 0">
<VoxDivider>{{LL.Speaker_talks()}}</VoxDivider>
<speaker-talk v-for="talk in speaker.talks" :focused-speaker="speaker" :talk="talk" :key="talk.id.value" />
<speaker-talk v-for="talk in speaker.talks" :key="talk.id.value"
:focused-speaker="speaker" :talk="talk" :conf-descriptor="confDescriptor"
:talk-stats="talkStatsRefByTalkId.get(talk.id.value)"
:talk-notes="userEventTalkNotesRef.get(talk.id.value)"
:local-event-talk-notes="localEventTalkNotesRef.get(talk.id.value)"
@talk-note-updated="userEventTalkNotesRef.set(talk.id.value, $event)"
/>
</div>

<div class="sectionBloc linksInfoSpeaker" v-if="speaker.social.length">
Expand Down Expand Up @@ -82,6 +88,9 @@ import SpeakerThumbnail from "@/components/speaker/SpeakerThumbnail.vue";
import SocialMediaIcon from "@/components/ui/SocialMediaIcon.vue";
import {useLineupSpeaker} from "@/state/useEventSpeakers";
import SpeakerTalk from "@/components/speaker-card/SpeakerTalk.vue";
import {useLocalEventTalkFavsStorage, useUserEventTalkNotes} from "@/state/useUserTalkNotes";
import {computed, toValue} from "vue";
import {useEventTalkStats} from "@/state/useEventTalkStats";
const LOGGER = Logger.named("SpeakerDetailsPage");
Expand All @@ -98,6 +107,20 @@ const {speaker} = useLineupSpeaker(confDescriptor, speakerId)
const { LL } = typesafeI18n()
const localEventTalkNotesRef = useLocalEventTalkFavsStorage(spacedEventIdRef)
const talkIdsRef = computed(() => {
const unreffedSpeaker = toValue(speaker);
if(!unreffedSpeaker) {
return [];
}
const uniqueTalkIds = unreffedSpeaker.talks.map(talk => talk.id);
return uniqueTalkIds;
})
const {userEventTalkNotesRef} = useUserEventTalkNotes(spacedEventIdRef, talkIdsRef)
const {firestoreEventTalkStatsRef: talkStatsRefByTalkId} = useEventTalkStats(spacedEventIdRef, talkIdsRef)
// * TODO #74 Check perf impact * //
const isScrollingDown = ref(false);
const handleScrollStart = () => {};
Expand Down
29 changes: 28 additions & 1 deletion mobile/src/views/event/SpeakersDirectoryPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
<speaker-card v-for="speaker in speakers" @speaker-clicked="openSpeakerDetails($event)" :confDescriptor="confDescriptor" :speaker="speaker" :key="speaker.id.value">
<template #content="{}">
<ion-list class="talkResumeList" :style="{ display: currentMode === 'detailed' ? 'block':'none' }">
<SpeakerTalk v-for="talk in speaker.talks" :talk="talk" :conf-descriptor="confDescriptor" :focused-speaker="speaker" :key="talk.id.value"></SpeakerTalk>
<speaker-talk v-for="talk in speaker.talks" :key="talk.id.value"
:talk="talk" :conf-descriptor="confDescriptor" :focused-speaker="speaker"
:talk-stats="talkStatsRefByTalkId.get(talk.id.value)"
:talk-notes="userEventTalkNotesRef.get(talk.id.value)"
:local-event-talk-notes="localEventTalkNotesRef.get(talk.id.value)"
@talk-note-updated="userEventTalkNotesRef.set(talk.id.value, $event)"
/>
</ion-list>
</template>
</speaker-card>
Expand Down Expand Up @@ -39,6 +45,10 @@
import {getResolvedEventRootPathFromSpacedEventIdRef, useCurrentSpaceEventIdRef} from "@/services/Spaces";
import {useLineupSpeakers} from "@/state/useEventSpeakers";
import SpeakerTalk from "@/components/speaker-card/SpeakerTalk.vue";
import {useLocalEventTalkFavsStorage, useUserEventTalkNotes} from "@/state/useUserTalkNotes";
import {computed, toValue} from "vue";
import {TalkId} from "@/models/VoxxrinTalk";
import {useEventTalkStats} from "@/state/useEventTalkStats";
const { LL } = typesafeI18n()
const spacedEventIdRef = useCurrentSpaceEventIdRef();
Expand All @@ -48,6 +58,23 @@
const searchTermsRef = ref<string|undefined>(undefined);
const { speakers } = useLineupSpeakers(confDescriptor, searchTermsRef)
const localEventTalkNotesRef = useLocalEventTalkFavsStorage(spacedEventIdRef)
const talkIdsRef = computed(() => {
const unreffedSpeakers = toValue(speakers);
if(!unreffedSpeakers) {
return [];
}
const uniqueRawTalkIds = unreffedSpeakers.reduce((rawTalkIds, speaker) => {
speaker.talks.forEach(talk => rawTalkIds.add(talk.id.value));
return rawTalkIds;
}, new Set<string>())
return [...uniqueRawTalkIds].map(rawTalkId => new TalkId(rawTalkId));
})
const {userEventTalkNotesRef} = useUserEventTalkNotes(spacedEventIdRef, talkIdsRef)
const {firestoreEventTalkStatsRef: talkStatsRefByTalkId} = useEventTalkStats(spacedEventIdRef, talkIdsRef)
const DEFAULT_MODE = 'compact';
const currentMode = ref<typeof MODES[number]['id']>(DEFAULT_MODE);
const MODES = [
Expand Down

0 comments on commit eb90111

Please sign in to comment.