tangled
alpha
login
or
join now
tokono.ma
/
diffuse
5
fork
atom
A music player that connects to your cloud/distributed storage.
5
fork
atom
overview
issues
4
pulls
pipelines
fix: atproto tracks.put
Steven Vandevelde
3 days ago
e55d811c
4f37b030
+12
-6
1 changed file
expand all
collapse all
unified
split
src
components
output
raw
atproto
element.js
+12
-6
src/components/output/raw/atproto/element.js
···
8
8
9
9
import { computed, signal } from "~/common/signal.js";
10
10
import { BroadcastedOutputElement, outputManager } from "../../common.js";
11
11
-
import * as Output from "~/common/output.js";
12
11
13
12
import {
14
13
clearStoredSession,
···
20
19
} from "./oauth.js";
21
20
22
21
/**
23
23
-
* @import {TrackBundle} from "~/definitions/types.d.ts"
22
22
+
* @import {Track, TrackBundle} from "~/definitions/types.d.ts"
24
23
* @import {OutputManager} from "../../types.d.ts"
25
24
* @import {ATProtoOutputElement} from "./types.d.ts"
26
25
*/
···
63
62
constructor() {
64
63
super();
65
64
65
65
+
/** @type {Track[] | null} */
66
66
+
let lastPersistedTracks = null;
67
67
+
66
68
/** @type {OutputManager} */
67
69
this.#manager = outputManager({
68
70
facets: {
···
82
84
"sh.diffuse.output.trackBundle",
83
85
);
84
86
85
85
-
return bundles.flatMap((bundle) => bundle.tracks ?? []);
87
87
+
const tracks = bundles.flatMap((bundle) => bundle.tracks ?? []);
88
88
+
lastPersistedTracks = tracks;
89
89
+
90
90
+
return tracks;
86
91
},
87
92
put: async (data) => {
88
88
-
const current = await Output.data(this.#manager.tracks);
89
89
-
const hashCurrent = xxh32r(encode(current));
93
93
+
const hashCurrent = xxh32r(encode(lastPersistedTracks ?? []));
90
94
const hashNew = xxh32r(encode(data));
91
95
92
96
if (hashCurrent === hashNew) {
···
104
108
});
105
109
}
106
110
107
107
-
return this.#putRecords("sh.diffuse.output.trackBundle", bundles, {
111
111
+
await this.#putRecords("sh.diffuse.output.trackBundle", bundles, {
108
112
upsertBatchSize: 1,
109
113
});
114
114
+
115
115
+
lastPersistedTracks = data;
110
116
},
111
117
},
112
118
});