68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
// Metro module 10944 (f10945).
|
|
import PresenceStore from "../stores/PresenceStore";
|
|
import { Endpoints } from "../Constants";
|
|
import Dispatcher from "../Dispatcher";
|
|
import { getSpotifyMetadataFromActivity } from "../modules/spotify/SpotifyUtils";
|
|
import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest";
|
|
export function sync(a0, a1) {
|
|
Dispatcher.dispatch({
|
|
type: "ACTIVITY_SYNC",
|
|
activity: a0,
|
|
userId: a1
|
|
});
|
|
}
|
|
export function play(a0, a1) {
|
|
const activity = a0;
|
|
const userId = a1;
|
|
getSpotifyMetadataFromActivity(a0, a1).then((result) => Dispatcher.dispatch({
|
|
type: "ACTIVITY_PLAY",
|
|
activity,
|
|
userId,
|
|
metadata: result
|
|
})).catch(() => Dispatcher.dispatch({
|
|
type: "ACTIVITY_PLAY",
|
|
activity,
|
|
userId
|
|
}));
|
|
}
|
|
export async function getMetadata(c26875_0, c26875_1) {
|
|
let r89, activityMetadata, metadata;
|
|
let c26875_3;
|
|
let c30311_0, c30311_1;
|
|
L18: {
|
|
L17: {
|
|
L10: {
|
|
c26875_3 = void 0;
|
|
c30311_0 = c26875_1;
|
|
c30311_1 = void 0;
|
|
metadata = c26875_0.metadata;
|
|
if (metadata != null && Object.keys(metadata).length > 0) {
|
|
break L10;
|
|
}
|
|
activityMetadata = PresenceStore.getActivityMetadata(c26875_1);
|
|
if (activityMetadata != null) {
|
|
break L18;
|
|
}
|
|
if (c26875_0.session_id == null) {
|
|
throw new Error("null/undefined session_id");
|
|
}
|
|
c30311_1 = (await HTTP.get({
|
|
url: Endpoints.USER_ACTIVITY_METADATA(c26875_1, c26875_0.session_id, c26875_0.application_id),
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
})).body;
|
|
Dispatcher.dispatch({
|
|
type: "ACTIVITY_METADATA_UPDATE",
|
|
metadata: c30311_1,
|
|
userId: c30311_0
|
|
});
|
|
r89 = c30311_1;
|
|
break L17;
|
|
}
|
|
return metadata;
|
|
}
|
|
return r89;
|
|
}
|
|
return activityMetadata;
|
|
}
|