36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
// Metro module 14352 (f14353).
|
|
import { useCallback } from "react";
|
|
import { AnalyticEvents } from "../../../Constants";
|
|
import { DisplayNameEffect } from "../../../_bundle/Module1887";
|
|
import { setTryItOutDisplayNameStyles } from "../../user_profile/UserProfileActionCreators";
|
|
import { setPendingChanges } from "../../user_profile/UserProfileSettingsActionCreators";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { DisplayNameFont } from "../../../_bundle/Module1888";
|
|
export function useDisplayNameStylesHandleApply({ hasChanges, selectedFontId, selectedEffectId, selectedColors, defaultColor, guildId, isTryItOut, onClose }) {
|
|
return useCallback(() => {
|
|
if (hasChanges) {
|
|
const displayNameStyles = {
|
|
fontId: selectedFontId,
|
|
effectId: selectedEffectId,
|
|
colors: selectedEffectId === DisplayNameEffect.SOLID && selectedColors.length > 0 && selectedColors[0] === defaultColor ? [] : selectedColors
|
|
};
|
|
if (isTryItOut) {
|
|
setTryItOutDisplayNameStyles(displayNameStyles);
|
|
} else {
|
|
setPendingChanges({
|
|
guildId,
|
|
displayNameStyles
|
|
});
|
|
}
|
|
AnalyticsUtils.track(AnalyticEvents.DISPLAY_NAME_STYLES_APPLIED, {
|
|
font_name: DisplayNameFont[selectedFontId],
|
|
effect_name: DisplayNameEffect[selectedEffectId],
|
|
colors: selectedColors
|
|
});
|
|
if (onClose != null) {
|
|
onClose();
|
|
}
|
|
}
|
|
}, [hasChanges, selectedFontId, selectedEffectId, selectedColors, defaultColor, onClose, guildId, isTryItOut]);
|
|
}
|