mirror of
https://github.com/FluxaMedia/fluxa-desktop.git
synced 2026-07-26 20:02:09 +00:00
use shared core business policies
This commit is contained in:
parent
dcbd7880e6
commit
87f209d7fb
4 changed files with 20 additions and 13 deletions
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
|
|
@ -2031,7 +2031,6 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.10.9",
|
||||
"url",
|
||||
"web-time",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ export const CORE_METHODS = [
|
|||
'createProfilePlan',
|
||||
'curateHomeItems',
|
||||
'dataFailurePolicy',
|
||||
'desktopCalendarNotificationPlan',
|
||||
'desktopCalendarReadPlan',
|
||||
'detailEpisodePlan',
|
||||
'detailSeasonLoadPlan',
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ async function deriveNextProgressFromLastWatched(metaObj: Record<string, unknown
|
|||
contentId: id,
|
||||
contentType: 'series',
|
||||
videoId: next.id,
|
||||
positionSeconds: 1,
|
||||
durationSeconds: 99999,
|
||||
positionSeconds: 0,
|
||||
durationSeconds: 0,
|
||||
lastWatched: Date.now(),
|
||||
season: next.season,
|
||||
episode: next.episode ?? next.number,
|
||||
|
|
@ -159,8 +159,8 @@ async function runEffect(
|
|||
lastVideoId: e.lastVideoId,
|
||||
lastEpisodeSeason: e.lastEpisodeSeason,
|
||||
lastEpisodeNumber: e.lastEpisodeNumber,
|
||||
timeOffset: 1,
|
||||
duration: 99999,
|
||||
timeOffset: 0,
|
||||
duration: 0,
|
||||
savedAt: e.savedAt,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ async function deriveNextProgressInfo(
|
|||
contentId: seriesId,
|
||||
contentType,
|
||||
videoId: next.id,
|
||||
positionSeconds: 1,
|
||||
durationSeconds: 99999,
|
||||
positionSeconds: 0,
|
||||
durationSeconds: 0,
|
||||
lastWatched: Date.now(),
|
||||
season: next.season,
|
||||
episode: next.episode ?? next.number,
|
||||
|
|
@ -137,11 +137,20 @@ async function deriveNextProgressInfo(
|
|||
export async function notifyReleasedEpisodes(payload: Record<string, unknown>): Promise<void> {
|
||||
const items = (payload.items as Array<Record<string, unknown>> | undefined) ?? [];
|
||||
const todayIso = new Date().toISOString().slice(0, 10);
|
||||
const plan = await coreInvoke<{ items: Array<Record<string, unknown>>; notifiedIds: string[] }>('desktopCalendarNotificationPlan', JSON.stringify({
|
||||
items,
|
||||
const plan = await coreInvoke<{ items: Array<Record<string, unknown>>; storedKeys: string[] }>('calendarNotificationContent', JSON.stringify({
|
||||
items: items.map((item) => ({
|
||||
...item,
|
||||
dateIso: String(item.dateIso ?? '').slice(0, 10),
|
||||
metaId: item.contentId ?? item.seriesId ?? item.metaId ?? item.id,
|
||||
metaType: item.metaType ?? item.type ?? 'series',
|
||||
artworkUrl: item.artworkUrl ?? item.poster,
|
||||
})),
|
||||
todayIso,
|
||||
notifiedIds: (await storageRead<string[]>(NOTIFIED_EPISODES_KEY)) ?? [],
|
||||
limit: 500,
|
||||
alreadyNotifiedKeys: (await storageRead<string[]>(NOTIFIED_EPISODES_KEY)) ?? [],
|
||||
profileId: await storageRead<string>('active_profile_id'),
|
||||
notificationsEnabled: true,
|
||||
alertNewEpisodes: true,
|
||||
maxStoredKeys: 500,
|
||||
}));
|
||||
if (!plan?.items.length) return;
|
||||
|
||||
|
|
@ -149,7 +158,7 @@ export async function notifyReleasedEpisodes(payload: Record<string, unknown>):
|
|||
const body = (item.episodeTitle as string | undefined) ?? (item.subtitle as string | undefined);
|
||||
void notify(t('notifications.new_episode_title', item.title as string), body);
|
||||
}
|
||||
await storageWrite(NOTIFIED_EPISODES_KEY, plan.notifiedIds);
|
||||
await storageWrite(NOTIFIED_EPISODES_KEY, plan.storedKeys);
|
||||
}
|
||||
|
||||
export async function applyLibraryCommand(payload: Record<string, unknown>): Promise<unknown> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue