Skip to content

Commit

Permalink
fix: allow other jwpubs for public media
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdvlpr committed Dec 4, 2024
1 parent 469023f commit 189cadb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
16 changes: 7 additions & 9 deletions src/components/media/PublicTalkMediaPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<script setup lang="ts">
import type { DocumentItem, MediaSection, PublicationInfo } from 'src/types';
import { storeToRefs } from 'pinia';
import { addJwpubDocumentMediaToFiles } from 'src/helpers/jw-media';
import { decompressJwpub } from 'src/helpers/mediaPlayback';
import { useCurrentStateStore } from 'src/stores/current-state';
Expand All @@ -97,7 +96,6 @@ const props = defineProps<{
const open = defineModel<boolean>({ required: true });
const currentState = useCurrentStateStore();
const { currentSettings } = storeToRefs(currentState);
const filter = ref('');
const publicTalks = ref<DocumentItem[]>([]);
Expand Down Expand Up @@ -149,20 +147,20 @@ const dismissPopup = () => {
const addPublicTalkMedia = (publicTalkDocId: DocumentItem) => {
if (!s34mpDb.value || !publicTalkDocId) return;
addJwpubDocumentMediaToFiles(
s34mpDb.value,
publicTalkDocId,
props.section,
).then(dismissPopup);
addJwpubDocumentMediaToFiles(s34mpDb.value, publicTalkDocId, props.section, {
issue: currentState.currentCongregation,
langwritten: currentState.currentSettings?.lang || 'E',
pub: 'S-34mp',
}).then(dismissPopup);
};
const setS34mp = async () => {
s34mpBasename.value = 'S-34mp_' + currentSettings.value?.lang + '_0';
s34mpBasename.value = `S-34mp_${currentState.currentSettings?.lang || 'E'}_${currentState.currentCongregation}`;
s34mpDir.value = path.join(await getPublicationsPath(), s34mpBasename.value);
};
watch(open, () => {
if (currentSettings.value?.lang) {
if (currentState.currentSettings?.lang) {
setS34mp().then(() => {
populatePublicTalks();
});
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/jw-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const addJwpubDocumentMediaToFiles = async (
dbPath: string,
document: DocumentItem,
section: MediaSection | undefined,
pubFolder?: PublicationFetcher,
) => {
const jwStore = useJwStore();
const { addToAdditionMediaMap } = jwStore;
Expand All @@ -202,7 +203,7 @@ export const addJwpubDocumentMediaToFiles = async (
for (let i = 0; i < multimediaItems.length; i++) {
multimediaItems[i] = await addFullFilePathToMultimediaItem(
multimediaItems[i],
publication,
pubFolder ?? publication,
);
}
await processMissingMediaInfo(multimediaItems);
Expand Down
4 changes: 3 additions & 1 deletion src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export const datesAreSame = (date1: Date, date2: Date) => {
if (!date1 || !date2) throw new Error('Missing date for comparison');
return date1.toDateString() === date2.toDateString();
} catch (error) {
errorCatcher(error);
errorCatcher(error, {
contexts: { fn: { date1, date2, name: 'datesAreSame' } },
});
return false;
}
};
Expand Down

0 comments on commit 189cadb

Please sign in to comment.