A music player that connects to your cloud/distributed storage.

chore: playlistItemBundle

+53 -3
+26 -3
src/components/output/raw/atproto/element.js
··· 14 14 } from "./oauth.js"; 15 15 16 16 /** 17 - * @import {TrackBundle} from "@definitions/types.d.ts" 17 + * @import {PlaylistItemBundle, TrackBundle} from "@definitions/types.d.ts" 18 18 * @import {OutputManager} from "../../types.d.ts" 19 19 * @import {ATProtoOutputElement} from "./types.d.ts" 20 20 */ ··· 52 52 }, 53 53 playlistItems: { 54 54 empty: () => [], 55 - get: () => this.listRecords("sh.diffuse.output.playlistItem"), 56 - put: (data) => this.#putRecords("sh.diffuse.output.playlistItem", data), 55 + get: async () => { 56 + const bundles = await this.listRecords( 57 + "sh.diffuse.output.playlistItemBundle", 58 + ); 59 + 60 + return bundles.flatMap((bundle) => bundle.playlistItems ?? []); 61 + }, 62 + put: (data) => { 63 + /** @type {PlaylistItemBundle[]} */ 64 + const bundles = []; 65 + 66 + for (let i = 0; i < data.length; i += 100) { 67 + bundles.push({ 68 + $type: "sh.diffuse.output.playlistItemBundle", 69 + id: TID.now(), 70 + playlistItems: data.slice(i, i + 100), 71 + }); 72 + } 73 + 74 + return this.#putRecords( 75 + "sh.diffuse.output.playlistItemBundle", 76 + bundles, 77 + { upsertBatchSize: 1 }, 78 + ); 79 + }, 57 80 }, 58 81 themes: { 59 82 empty: () => [],
+23
src/definitions/output/playlistItemBundle.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "sh.diffuse.output.playlistItemBundle", 4 + "defs": { 5 + "main": { 6 + "type": "record", 7 + "record": { 8 + "type": "object", 9 + "required": ["id", "playlistItems"], 10 + "properties": { 11 + "id": { "type": "string" }, 12 + "createdAt": { "type": "string", "format": "datetime" }, 13 + "playlistItems": { 14 + "type": "array", 15 + "description": "A bundle of playlist items", 16 + "items": { "type": "ref", "ref": "sh.diffuse.output.playlistItem" } 17 + }, 18 + "updatedAt": { "type": "string", "format": "datetime" } 19 + } 20 + } 21 + } 22 + } 23 + }
+4
src/definitions/types.d.ts
··· 15 15 } from "./types/sh/diffuse/output/track.ts"; 16 16 17 17 export type { 18 + Main as PlaylistItemBundle, 19 + } from "./types/sh/diffuse/output/playlistItemBundle.ts"; 20 + 21 + export type { 18 22 Main as TrackBundle, 19 23 } from "./types/sh/diffuse/output/trackBundle.ts";