Skip to content

Commit

Permalink
feat: allow time entry for custom durations; show time elapsed and re…
Browse files Browse the repository at this point in the history
…maining during video playback (#3661)

* fix: groundwork to allow time entry for custom durations

* fix: add elapsed time

* fix: timeToSeconds

* fix: logic fixes

* fix: more logic fixes and linting

* fix: media tag editing was broken

* fix: properly set initial tag value on edit

* fix: tag typing

* fix: repeat and custom duration was not working as intended

---------

Co-authored-by: Manoah Tervoort <[email protected]>
  • Loading branch information
sircharlo and mtdvlpr authored Dec 9, 2024
1 parent f3dcc98 commit d3c9ca4
Show file tree
Hide file tree
Showing 12 changed files with 332 additions and 253 deletions.
34 changes: 6 additions & 28 deletions src/components/dialog/DialogAudioBible.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,14 @@ import type {
} from 'src/types';
import { whenever } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import { errorCatcher } from 'src/helpers/error-catcher';
import {
downloadAdditionalRemoteVideo,
getAudioBibleMedia,
} from 'src/helpers/jw-media';
import { useCurrentStateStore } from 'src/stores/current-state';
import { useJwStore } from 'src/stores/jw';
import { timeToSeconds } from 'src/utils/time';
import { computed, ref, watch } from 'vue';
// Stores
const currentStateStore = useCurrentStateStore();
const { currentCongregation, selectedDate } = storeToRefs(currentStateStore);
const jwStore = useJwStore();
const { customDurations } = storeToRefs(jwStore);
// Props
const props = defineProps<{
section: MediaSection | undefined;
Expand Down Expand Up @@ -337,11 +329,6 @@ const addSelectedVerses = async () => {
const startVerseNumber = chosenVerses.value[0];
const endVerseNumber = chosenVerses.value[1] || startVerseNumber;
const timeToSeconds = (time: string) => {
const [h, m, s] = time.split(':').map(parseFloat);
return (h ?? 0) * 3600 + (m ?? 0) * 60 + (s ?? 0);
};
const min = timeToSeconds(
selectedChapterMedia.value.map((item) =>
item.markers.markers.find(
Expand All @@ -359,7 +346,7 @@ const addSelectedVerses = async () => {
? timeToSeconds(endVerse.startTime) + timeToSeconds(endVerse.duration)
: 0;
const uniqueId = await downloadAdditionalRemoteVideo(
await downloadAdditionalRemoteVideo(
selectedChapterMedia.value,
undefined,
false,
Expand All @@ -371,21 +358,12 @@ const addSelectedVerses = async () => {
.filter((verse, index, self) => self.indexOf(verse) === index)
.join('-'),
props.section,
{
max,
min,
},
);
if (
uniqueId &&
min &&
max &&
selectedDate.value &&
currentCongregation.value
) {
const congregation = (customDurations.value[currentCongregation.value] ??=
{});
const dateDurations = (congregation[selectedDate.value] ??= {});
dateDurations[uniqueId] = { max, min };
}
resetBibleBook(true, true);
loading.value = false;
Expand Down
Loading

0 comments on commit d3c9ca4

Please sign in to comment.