decord/source/actions/UserSettingsActionCreators.tsx

352 lines
14 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 9402
// Function ID: 9403
2026-07-29 08:29:29 +00:00
// Name: saveGuildFolders
2026-08-24 06:08:38 +00:00
// Dependencies: [5, 4199, 1303, 1302, 676, 1305, 1374, 1306, 1337, 709, 4226, 4069, 2]
2026-07-20 16:05:17 +00:00
// Exports: saveClientTheme, saveGuildFolders
2026-08-24 06:08:38 +00:00
// Module 9402 (saveGuildFolders)
import dispatcherDefault from "dispatcher" /* 709 */;
import explicitContentFromProto from "explicitContentFromProto" /* 4069 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
import closure_4 from "isSyncedModeThemesEnabled" /* 4199 */;
import closure_5 from "initialize" /* 1303 */;
import closure_6 from "handleThemeChange" /* 1302 */;
import { ThemeTypes } from "ME" /* 676 */;
import SystemThemeState from "SystemThemeState" /* 1305 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
({ SystemTheme, SystemThemeState: closure_8 } = SystemThemeState);
let result = require("set").fileFinishedImporting("actions/UserSettingsActionCreators.tsx");
2026-07-23 10:11:24 +00:00
export default {
2026-07-20 16:05:17 +00:00
overrideLocale(locale) {
2026-08-24 06:08:38 +00:00
let obj = dispatcherDefault;
2026-07-20 16:05:17 +00:00
obj = { type: "USER_SETTINGS_LOCALE_OVERRIDE", locale };
obj.dispatch(obj);
},
updatedUnsyncedSettings(settings) {
2026-08-24 06:08:38 +00:00
let obj = dispatcherDefault;
2026-07-20 16:05:17 +00:00
obj = { type: "UNSYNCED_USER_SETTINGS_UPDATE", settings };
obj.dispatch(obj);
},
setShouldSyncTextSettings(shouldSync) {
2026-08-24 06:08:38 +00:00
let obj = dispatcherDefault;
2026-07-29 08:29:29 +00:00
obj = { shouldSync, settings: null };
2026-07-20 16:05:17 +00:00
if (shouldSync) {
2026-07-29 08:29:29 +00:00
obj = {};
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
obj = { inlineAttachmentMedia: null, inlineEmbedMedia: null, renderEmbeds: null, renderReactions: null, animateEmoji: null, animateStickers: null, gifAutoPlay: null };
2026-08-24 06:08:38 +00:00
const InlineAttachmentMedia = explicitContentFromProto.InlineAttachmentMedia;
2026-07-29 08:29:29 +00:00
obj[0] = InlineAttachmentMedia.getSetting();
2026-08-24 06:08:38 +00:00
const InlineEmbedMedia = explicitContentFromProto.InlineEmbedMedia;
2026-07-29 08:29:29 +00:00
obj[1] = InlineEmbedMedia.getSetting();
2026-08-24 06:08:38 +00:00
const RenderEmbeds = explicitContentFromProto.RenderEmbeds;
2026-07-29 08:29:29 +00:00
obj[2] = RenderEmbeds.getSetting();
2026-08-24 06:08:38 +00:00
const RenderReactions = explicitContentFromProto.RenderReactions;
2026-07-29 08:29:29 +00:00
obj[3] = RenderReactions.getSetting();
2026-08-24 06:08:38 +00:00
const AnimateEmoji = explicitContentFromProto.AnimateEmoji;
2026-07-29 08:29:29 +00:00
obj[4] = AnimateEmoji.getSetting();
2026-08-24 06:08:38 +00:00
const AnimateStickers = explicitContentFromProto.AnimateStickers;
2026-07-29 08:29:29 +00:00
obj[5] = AnimateStickers.getSetting();
2026-08-24 06:08:38 +00:00
const GifAutoPlay = explicitContentFromProto.GifAutoPlay;
2026-07-29 08:29:29 +00:00
obj[6] = GifAutoPlay.getSetting();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[1] = obj;
obj.dispatch({ type: "SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE", changes: { text: obj } });
2026-07-20 16:05:17 +00:00
},
setShouldSyncAppearanceSettings(is_sync_enabled) {
2026-08-24 06:08:38 +00:00
closure_0 = is_sync_enabled;
2026-07-29 08:29:29 +00:00
return callback(function*() {
if (c3 === 2) {
c3 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c3 = 2;
if (0 === v0) {
if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_0 = tmp3;
if (closure_1_0) {
dependencyMap = 1;
const PreloadedUserSettingsActionCreators = closure_1_0(1374).PreloadedUserSettingsActionCreators;
2026-07-29 08:29:29 +00:00
v0 = 2;
c3 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
2026-07-29 08:29:29 +00:00
obj1[0] = PreloadedUserSettingsActionCreators.updateAsync("appearance", (arg0) => {
theme = theme.theme;
if (constants.DARK === theme) {
let DARK = tmp3(1306).Theme.DARK;
tmp3 = dependencyMap;
let tmp4 = tmp3;
} else if (tmp.LIGHT === theme) {
DARK = tmp3(1306).Theme.LIGHT;
tmp3 = dependencyMap;
tmp4 = tmp3;
} else if (tmp.DARKER === theme) {
DARK = tmp3(1306).Theme.DARKER;
tmp3 = dependencyMap;
tmp4 = tmp3;
} else if (tmp.MIDNIGHT === theme) {
DARK = tmp3(1306).Theme.MIDNIGHT;
tmp3 = dependencyMap;
tmp4 = tmp3;
} else {
tmp3 = dependencyMap;
DARK = tmp3(1306).Theme.DARK;
tmp4 = tmp3;
}
arg0.theme = DARK;
gradientPreset = gradientPreset.gradientPreset;
let id;
if (gradientPreset != null) {
id = gradientPreset.id;
}
2026-08-24 06:08:38 +00:00
const ClientThemeSettings = tmp4(4069).ClientThemeSettings;
2026-07-29 08:29:29 +00:00
const setting = ClientThemeSettings.getSetting();
let prop;
if (setting != null) {
prop = setting.customUserThemeSettings;
}
let obj;
if (null != id) {
const UInt32Value = tmp4(1337).UInt32Value;
obj = { value: null };
obj[0] = id;
obj = UInt32Value.create(obj);
}
obj = { backgroundGradientPresetId: obj, customUserThemeSettings: null };
let tmp17;
if (null != prop) {
({ colors: obj3[0], gradientColorStops: obj3[1], gradientAngle: obj3[2], baseMix: obj3[3] } = prop);
tmp17 = { colors: null, gradientColorStops: null, gradientAngle: null, baseMix: null };
2026-08-24 06:08:38 +00:00
obj1 = { colors: null, gradientColorStops: null, gradientAngle: null, baseMix: null };
2026-07-29 08:29:29 +00:00
}
obj[1] = tmp17;
arg0.clientThemeSettings = obj;
2026-08-24 06:08:38 +00:00
}, closure_1_0(1374).UserSettingsDelay.INFREQUENT_USER_ACTION);
2026-07-29 08:29:29 +00:00
return obj1;
}
}
} else if (1 === tmp7) {
dependencyMap = 0;
c3 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
} else if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
dependencyMap = 0;
c3 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
dependencyMap = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj1 = v0(709);
const obj2 = { shouldSync: null, settings: null };
obj2[0] = closure_0;
if (closure_0) {
let obj3 = {};
} else {
obj3 = { theme: null, clientThemeSettings: null, developerMode: null };
2026-08-24 06:08:38 +00:00
obj3[0] = closure_1_6.theme;
let gradientPreset = closure_1_4.gradientPreset;
2026-07-29 08:29:29 +00:00
let id;
if (gradientPreset != null) {
id = gradientPreset.id;
}
2026-08-06 08:05:19 +00:00
const obj4 = { backgroundGradientPresetId: null, customUserThemeSettings: null };
2026-07-29 08:29:29 +00:00
obj4[0] = id;
2026-08-24 06:08:38 +00:00
let ClientThemeSettings = closure_1_0(4069).ClientThemeSettings;
2026-08-06 08:05:19 +00:00
obj4[1] = ClientThemeSettings.getSetting().customUserThemeSettings;
2026-07-29 08:29:29 +00:00
obj3[1] = obj4;
2026-08-24 06:08:38 +00:00
const DeveloperMode = closure_1_0(4069).DeveloperMode;
2026-07-29 08:29:29 +00:00
obj3[2] = DeveloperMode.getSetting();
}
const obj5 = { type: "SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE", changes: null };
const obj6 = { appearance: null };
obj2[1] = obj3;
obj6[0] = obj2;
obj5[1] = obj6;
obj1.dispatch(obj5);
c3 = 3;
2026-08-06 08:05:19 +00:00
} catch (tmp27) {
2026-07-29 08:29:29 +00:00
if (tmp4 === dependencyMap) {
c3 = tmp2;
2026-08-06 08:05:19 +00:00
throw tmp27;
2026-07-29 08:29:29 +00:00
} else {
v0 = tmp;
2026-07-20 16:05:17 +00:00
}
}
}
})();
},
applySettingsOverride(settings) {
2026-08-24 06:08:38 +00:00
let obj = dispatcherDefault;
2026-07-20 16:05:17 +00:00
obj = { type: "USER_SETTINGS_OVERRIDE_APPLY", settings };
obj.dispatch(obj);
},
clearSettingsOverride(gifAutoPlay, animateEmoji, animateStickers) {
const items = [...arguments];
2026-08-24 06:08:38 +00:00
dispatcherDefault.dispatch({ type: "USER_SETTINGS_OVERRIDE_CLEAR", settings: items });
2026-07-20 16:05:17 +00:00
},
updateLocale(arg0) {
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-08-11 06:20:06 +00:00
const PreloadedUserSettingsActionCreators = _require(1374).PreloadedUserSettingsActionCreators;
2026-07-20 16:05:17 +00:00
return PreloadedUserSettingsActionCreators.updateAsync("localization", (arg0) => {
2026-08-24 06:08:38 +00:00
const StringValue = callback(closure_1_2[8]).StringValue;
2026-07-23 10:11:24 +00:00
arg0.locale = StringValue.create({ value: callback });
2026-08-11 06:20:06 +00:00
}, _require(1374).UserSettingsDelay.INFREQUENT_USER_ACTION);
2026-07-20 16:05:17 +00:00
},
updateTheme(theme) {
2026-07-23 10:11:24 +00:00
const _require = theme;
2026-08-24 06:08:38 +00:00
let obj = dispatcherDefault;
2026-07-20 16:05:17 +00:00
obj = { theme };
obj.dispatch({ type: "SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE", changes: { appearance: { settings: obj } } });
2026-08-24 06:08:38 +00:00
if (closure_5.shouldSync("appearance")) {
2026-08-11 06:20:06 +00:00
const PreloadedUserSettingsActionCreators = _require(1374).PreloadedUserSettingsActionCreators;
2026-07-20 16:05:17 +00:00
PreloadedUserSettingsActionCreators.updateAsync("appearance", (arg0) => {
2026-08-24 06:08:38 +00:00
if (closure_1_7.DARK === theme) {
let DARK = theme(closure_1_2[7]).Theme.DARK;
2026-07-29 08:29:29 +00:00
} else if (tmp2.LIGHT === tmp) {
2026-08-24 06:08:38 +00:00
DARK = theme(closure_1_2[7]).Theme.LIGHT;
2026-07-29 08:29:29 +00:00
} else if (tmp2.DARKER === tmp) {
2026-08-24 06:08:38 +00:00
DARK = theme(closure_1_2[7]).Theme.DARKER;
2026-07-29 08:29:29 +00:00
} else if (tmp2.MIDNIGHT === tmp) {
2026-08-24 06:08:38 +00:00
DARK = theme(closure_1_2[7]).Theme.MIDNIGHT;
2026-07-29 08:29:29 +00:00
} else {
2026-08-24 06:08:38 +00:00
DARK = theme(closure_1_2[7]).Theme.DARK;
2026-07-29 08:29:29 +00:00
}
arg0.theme = DARK;
2026-08-11 06:20:06 +00:00
}, _require(1374).UserSettingsDelay.INFREQUENT_USER_ACTION);
2026-07-20 16:05:17 +00:00
}
}
};
export const saveGuildFolders = function saveGuildFolders(compatibleGuildFolders) {
2026-07-23 10:11:24 +00:00
const _require = compatibleGuildFolders;
2026-08-11 06:20:06 +00:00
const PreloadedUserSettingsActionCreators = _require(1374).PreloadedUserSettingsActionCreators;
2026-07-20 16:05:17 +00:00
return PreloadedUserSettingsActionCreators.updateAsync("guildFolders", (arg0) => {
2026-07-23 10:11:24 +00:00
arg0.folders = compatibleGuildFolders.map((guildIds) => {
2026-07-29 08:29:29 +00:00
const GuildFolder = callback(table[7]).GuildFolder;
2026-07-20 16:05:17 +00:00
let obj = { guildIds: guildIds.guildIds };
obj = GuildFolder.create(obj);
if (null != guildIds.folderId) {
2026-07-29 08:29:29 +00:00
const Int64Value = tmp(tmp2[8]).Int64Value;
obj = { value: null };
2026-07-20 16:05:17 +00:00
const _String = String;
2026-07-29 08:29:29 +00:00
obj[0] = String(guildIds.folderId);
2026-07-20 16:05:17 +00:00
obj.id = Int64Value.create(obj);
}
if (null != guildIds.folderColor) {
2026-07-29 08:29:29 +00:00
const UInt64Value = tmp(tmp2[8]).UInt64Value;
2026-08-24 06:08:38 +00:00
obj1 = { value: null };
2026-07-20 16:05:17 +00:00
const _String2 = String;
2026-07-29 08:29:29 +00:00
obj1[0] = String(guildIds.folderColor);
2026-07-20 16:05:17 +00:00
obj.color = UInt64Value.create(obj1);
}
2026-07-29 08:29:29 +00:00
let tmp6 = null != guildIds.folderName;
if (tmp6) {
tmp6 = "" !== guildIds.folderName;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp6) {
const StringValue = tmp(tmp2[8]).StringValue;
const obj2 = { value: null };
2026-07-20 16:05:17 +00:00
const _String3 = String;
2026-07-29 08:29:29 +00:00
obj2[0] = String(guildIds.folderName);
2026-07-20 16:05:17 +00:00
obj.name = StringValue.create(obj2);
}
return obj;
});
2026-08-11 06:20:06 +00:00
}, _require(1374).UserSettingsDelay.FREQUENT_USER_ACTION);
2026-07-20 16:05:17 +00:00
};
export const saveClientTheme = function saveClientTheme(backgroundGradientPresetId, INFREQUENT_USER_ACTION) {
backgroundGradientPresetId = backgroundGradientPresetId.backgroundGradientPresetId;
const customUserThemeSettings = backgroundGradientPresetId.customUserThemeSettings;
const theme = backgroundGradientPresetId.theme;
const useSystemTheme = backgroundGradientPresetId.useSystemTheme;
if (INFREQUENT_USER_ACTION === undefined) {
2026-07-23 10:11:24 +00:00
INFREQUENT_USER_ACTION = backgroundGradientPresetId(theme[6]).UserSettingsDelay.INFREQUENT_USER_ACTION;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let obj = customUserThemeSettings(theme[9]);
2026-07-29 08:29:29 +00:00
obj = { clientThemeSettings: { backgroundGradientPresetId, customUserThemeSettings }, theme: null };
2026-08-06 08:05:19 +00:00
let tmp6;
2026-07-20 16:05:17 +00:00
if ("system" !== theme) {
2026-08-06 08:05:19 +00:00
tmp6 = theme;
}
obj[1] = tmp6;
obj.dispatch({ type: "SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE", changes: { appearance: { settings: obj } } });
let tmp9 = tmp5 ? tmp8.ON : tmp8.OFF;
if (null != useSystemTheme) {
tmp9 = useSystemTheme;
}
customUserThemeSettings(theme[9]).dispatch({ type: "UNSYNCED_USER_SETTINGS_UPDATE", settings: { useSystemTheme: tmp9 } });
if (sameAsDeviceThemeEnabled.isSameAsDeviceThemeEnabled()) {
const result = backgroundGradientPresetId(tmp4[10]).clearSyncedClientThemes();
const obj4 = backgroundGradientPresetId(tmp4[10]);
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
if (closure_5.shouldSync("appearance")) {
2026-08-06 08:05:19 +00:00
const PreloadedUserSettingsActionCreators = backgroundGradientPresetId(tmp4[6]).PreloadedUserSettingsActionCreators;
2026-07-20 16:05:17 +00:00
return PreloadedUserSettingsActionCreators.updateAsync("appearance", (arg0) => {
2026-08-24 06:08:38 +00:00
if (closure_1_7.DARK === theme) {
2026-07-29 08:29:29 +00:00
let DARK = backgroundGradientPresetId(theme[7]).Theme.DARK;
let tmp4 = theme;
let tmp3 = backgroundGradientPresetId;
} else if (tmp2.LIGHT === tmp) {
DARK = backgroundGradientPresetId(theme[7]).Theme.LIGHT;
tmp4 = theme;
tmp3 = backgroundGradientPresetId;
} else if (tmp2.DARKER === tmp) {
DARK = backgroundGradientPresetId(theme[7]).Theme.DARKER;
tmp4 = theme;
tmp3 = backgroundGradientPresetId;
} else if (tmp2.MIDNIGHT === tmp) {
DARK = backgroundGradientPresetId(theme[7]).Theme.MIDNIGHT;
tmp4 = theme;
tmp3 = backgroundGradientPresetId;
} else {
tmp3 = backgroundGradientPresetId;
tmp4 = theme;
DARK = backgroundGradientPresetId(theme[7]).Theme.DARK;
}
arg0.theme = DARK;
let obj;
if (null != backgroundGradientPresetId) {
const UInt32Value = tmp3(tmp4[8]).UInt32Value;
obj = { value: null };
obj[0] = tmp13;
obj = UInt32Value.create(obj);
}
obj = { backgroundGradientPresetId: obj, customUserThemeSettings: null };
let tmp16;
if (null != customUserThemeSettings) {
({ colors: obj3[0], gradientColorStops: obj3[1], gradientAngle: obj3[2], baseMix: obj3[3] } = tmp14);
tmp16 = { colors: null, gradientColorStops: null, gradientAngle: null, baseMix: null };
2026-08-24 06:08:38 +00:00
obj1 = { colors: null, gradientColorStops: null, gradientAngle: null, baseMix: null };
2026-07-29 08:29:29 +00:00
}
obj[1] = tmp16;
arg0.clientThemeSettings = obj;
2026-07-20 16:05:17 +00:00
}, INFREQUENT_USER_ACTION);
}
2026-08-06 08:05:19 +00:00
let tmp3 = customUserThemeSettings;
const tmp3Result = customUserThemeSettings(theme[9]);
2026-07-20 16:05:17 +00:00
};