121 lines
4.0 KiB
TypeScript
121 lines
4.0 KiB
TypeScript
// Metro module 8844 (f8845).
|
|
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
|
|
import MediaEngineStore from "../../stores/MediaEngineStore";
|
|
import SelectedChannelStore from "../../stores/SelectedChannelStore";
|
|
import UserStore from "../../stores/UserStore";
|
|
import { getVideoBackgroundOptionFromProto } from "./VideoBackgroundUtils";
|
|
import { FilterSettingsKey } from "../../_bundle/Module4286";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let c5767_6, voiceChannelId, c5767_8, c5767_9, c5767_10, c5767_11;
|
|
const handleSyncedStoresUpdate = function handleSyncedStoresUpdate() {
|
|
if (voiceChannelId !== SelectedChannelStore.getVoiceChannelId()) {
|
|
c5767_8 = false;
|
|
c5767_10 = false;
|
|
c5767_11 = false;
|
|
}
|
|
const currentUser = UserStore.getCurrentUser();
|
|
const r2 = currentUser == null;
|
|
let r16 = false;
|
|
if (!r2) {
|
|
const videoBackgroundOptionFromProto = getVideoBackgroundOptionFromProto(UserSettingsProtoStore.settings.voiceAndVideo?.videoBackgroundFilterDesktop, currentUser.id);
|
|
r16 = SelectedChannelStore.getVoiceChannelId() != null && MediaEngineStore.isVideoEnabled() && videoBackgroundOptionFromProto != null;
|
|
}
|
|
if (r16) {
|
|
c5767_8 = true;
|
|
}
|
|
voiceChannelId = SelectedChannelStore.getVoiceChannelId();
|
|
};
|
|
c5767_6 = false;
|
|
voiceChannelId = null;
|
|
c5767_8 = false;
|
|
c5767_9 = {};
|
|
c5767_10 = false;
|
|
c5767_11 = false;
|
|
class VideoBackgroundStore extends Module589.Store {
|
|
static displayName = "VideoBackgroundStore";
|
|
initialize() {
|
|
this.waitFor(MediaEngineStore, SelectedChannelStore, UserSettingsProtoStore, UserStore);
|
|
this.syncWith([SelectedChannelStore, MediaEngineStore], handleSyncedStoresUpdate);
|
|
}
|
|
get videoFilterAssets() {
|
|
return c5767_9;
|
|
}
|
|
get hasBeenApplied() {
|
|
return c5767_6;
|
|
}
|
|
get hasUsedBackgroundInCall() {
|
|
return c5767_8;
|
|
}
|
|
get videoBackgroundUnavailable() {
|
|
return c5767_10;
|
|
}
|
|
get videoBackgroundPreviewUnavailable() {
|
|
return c5767_11;
|
|
}
|
|
}
|
|
const videoBackgroundStore = new VideoBackgroundStore(Dispatcher, {
|
|
VIDEO_FILTER_ASSETS_FETCH_SUCCESS: function handleVideoFilterAssetFetchSuccess({ assets }) {
|
|
const r5 = {};
|
|
let c16824_0 = r5;
|
|
assets.forEach((asset) => {
|
|
c16824_0[asset.id] = asset;
|
|
return asset;
|
|
});
|
|
c5767_9 = r5;
|
|
},
|
|
VIDEO_FILTER_ASSET_UPLOAD_SUCCESS: function handleAddBackground({ videoFilterAsset }) {
|
|
const r7 = {
|
|
...c5767_9
|
|
};
|
|
r7[videoFilterAsset.id] = videoFilterAsset;
|
|
c5767_9 = r7;
|
|
},
|
|
VIDEO_FILTER_ASSET_DELETE_SUCCESS: function handleRemoveBackground({ videoFilterAsset }) {
|
|
const r2 = {
|
|
...c5767_9
|
|
};
|
|
c5767_9 = r2;
|
|
delete r2[videoFilterAsset.id];
|
|
},
|
|
VIDEO_SAVE_LAST_USED_BACKGROUND_OPTION: function handleSaveLastUsedBackgroundOption({ backgroundOption }) {
|
|
const currentUser = UserStore.getCurrentUser();
|
|
const r2 = currentUser == null;
|
|
let r13 = false;
|
|
if (!r2) {
|
|
if (backgroundOption == null) {
|
|
backgroundOption = getVideoBackgroundOptionFromProto(UserSettingsProtoStore.settings.voiceAndVideo?.videoBackgroundFilterDesktop, currentUser.id);
|
|
}
|
|
r13 = SelectedChannelStore.getVoiceChannelId() != null && MediaEngineStore.isVideoEnabled() && backgroundOption != null;
|
|
}
|
|
if (r13) {
|
|
c5767_8 = true;
|
|
}
|
|
},
|
|
MEDIA_ENGINE_APPLY_MEDIA_FILTER_SETTINGS: function handleApplyMediaFilterSettings({ settings }) {
|
|
if (FilterSettingsKey.CAMERA_BACKGROUND_LIVE in settings) {
|
|
c5767_6 = true;
|
|
c5767_10 = false;
|
|
}
|
|
if (FilterSettingsKey.CAMERA_BACKGROUND_PREVIEW in settings) {
|
|
c5767_11 = false;
|
|
}
|
|
},
|
|
MEDIA_ENGINE_VIDEO_FILTER_ERROR: function handleVideoFilterError(a0) {
|
|
if (a0.target === "live") {
|
|
c5767_10 = true;
|
|
} else {
|
|
c5767_11 = true;
|
|
}
|
|
},
|
|
LOGOUT: function handleLogout() {
|
|
c5767_6 = false;
|
|
c5767_8 = false;
|
|
voiceChannelId = null;
|
|
c5767_9 = {};
|
|
c5767_10 = false;
|
|
c5767_11 = false;
|
|
}
|
|
});
|
|
export default videoBackgroundStore;
|