1 parent
51a320b31f
commit
d700543eba
28 files changed
+559
-19
No files matched your search
+6
-1
@@ -1,5 +1,5 @@
|
||||
import { t } from '../i18n'
|
||||
import type { BackupFile, Criteria, CustomList, MediaItem, MediaType, Settings, TopCategory, TopEntry, WatchStatus } from '../types'
|
||||
import type { BackupFile, Criteria, CustomList, MediaItem, MediaType, NotifPrefs, Settings, TopCategory, TopEntry, WatchStatus } from '../types'
|
||||
import { ALL_TOP_CATEGORIES, MEDIA_TYPES, STATUSES } from './constants'
|
||||
import { episodeCap } from './franchise'
|
||||
import { convertLegacyBackup, isLegacyBackup } from './legacyImport'
|
||||
@@ -130,6 +130,11 @@ export function normalizeSettings(raw: unknown): Partial<Settings> | undefined {
|
||||
if (Array.isArray(raw.topCategories)) out.topCategories = ALL_TOP_CATEGORIES.filter((c) => (raw.topCategories as unknown[]).includes(c))
|
||||
if (isHexColor(raw.accentColor)) out.accentColor = raw.accentColor.toLowerCase()
|
||||
if (raw.themeMode === 'auto' || raw.themeMode === 'light' || raw.themeMode === 'dark' || raw.themeMode === 'night' || raw.themeMode === 'starfield') out.themeMode = raw.themeMode
|
||||
if (isPlainObject(raw.notifPrefs)) {
|
||||
const np: NotifPrefs = {}
|
||||
for (const k of ['episodes', 'follows', 'accepted', 'reactions'] as const) if (typeof raw.notifPrefs[k] === 'boolean') np[k] = raw.notifPrefs[k] as boolean
|
||||
out.notifPrefs = np
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { cloudFetch } from './api'
|
||||
|
||||
/** Notifications (cloche) : abonnements, demandes acceptées, réactions reçues. */
|
||||
|
||||
export type NotificationKind = 'follow_request' | 'follow_accepted' | 'new_follower' | 'reaction'
|
||||
export type NotificationKind = 'follow_request' | 'follow_accepted' | 'new_follower' | 'reaction' | 'new_episode' | 'new_season'
|
||||
|
||||
export interface AppNotification {
|
||||
id: number
|
||||
@@ -12,11 +12,36 @@ export interface AppNotification {
|
||||
read_at: string | null
|
||||
emoji: string | null
|
||||
item_id: string | null
|
||||
/** Numéro du dernier épisode sorti (épisodes) */
|
||||
episode: number | null
|
||||
/** Nombre de nouveaux épisodes (épisodes) */
|
||||
ep_count: number | null
|
||||
actor: { username: string; display_name: string; avatar_url: string | null } | null
|
||||
/** Titre de la fiche concernée (réactions) */
|
||||
/** Titre de la fiche concernée (réactions, épisodes) */
|
||||
title: string | null
|
||||
}
|
||||
|
||||
/** Épisode/saison à signaler (envoyé après la vérification des sorties). */
|
||||
export interface EpisodeNotice {
|
||||
item_id: string
|
||||
kind: 'new_episode' | 'new_season'
|
||||
/** Dernier épisode sorti */
|
||||
episode: number
|
||||
/** Nombre de nouveaux épisodes */
|
||||
count: number
|
||||
}
|
||||
|
||||
/** Enregistre les nouveaux épisodes des séries suivies (dédoublonné côté serveur). Renvoie le nombre créé. */
|
||||
export async function addEpisodeNotifications(list: EpisodeNotice[]): Promise<number> {
|
||||
if (!list.length) return 0
|
||||
try {
|
||||
const n = await rpc<number>('add_episode_notifications', { p_list: list })
|
||||
return typeof n === 'number' ? n : 0
|
||||
} catch {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
async function rpc<T>(name: string, args: Record<string, unknown> = {}): Promise<T> {
|
||||
const res = await cloudFetch(`/rest/v1/rpc/${name}`, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -15,7 +15,7 @@ import { cloudFetch } from './api'
|
||||
* En cas de conflit, la modification la plus récente gagne (vérifié aussi par la base).
|
||||
*/
|
||||
|
||||
export type SyncedSettings = Pick<Settings, 'ratingScale' | 'topCategories' | 'accentColor' | 'themeMode'>
|
||||
export type SyncedSettings = Pick<Settings, 'ratingScale' | 'topCategories' | 'accentColor' | 'themeMode' | 'notifPrefs'>
|
||||
|
||||
export interface SyncHooks {
|
||||
getLists: () => CustomList[]
|
||||
|
||||
Reference in new issue
Block a user