Skip to content

Commit

Permalink
Edit supergroup colors fix
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Apr 17, 2024
1 parent 9b952ac commit 48eda05
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions Telegram/ViewModels/Supergroups/SupergroupProfileColorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum ChatBoostFeature
CustomEmojiStickerSet,
ChatTheme,
CustomBackground,
DisableSponsoredMessages
}

public class SupergroupProfileColorViewModel : ViewModelBase
Expand Down Expand Up @@ -298,43 +299,62 @@ private int UpdateRequiredLevel(out ChatBoostFeature feature)

var level = 0;

if (SelectedAccentColor != null && SelectedAccentColor.MinChannelChatBoostLevel > level)
if (Chat is not Chat chat)
{
return level;
}

var accentColorId = SelectedAccentColor?.Id ?? -1;
var profileAccentColorId = SelectedProfileAccentColor?.Id ?? -1;

if (accentColorId != -1 && accentColorId != chat.AccentColorId && SelectedAccentColor.MinChannelChatBoostLevel > level)
{
feature = ChatBoostFeature.AccentColor;
level = SelectedAccentColor.MinChannelChatBoostLevel;
}

if (SelectedCustomEmojiId != 0 && MinBackgroundCustomEmojiBoostLevel > level)
if (SelectedCustomEmojiId != 0 && SelectedCustomEmojiId != chat.BackgroundCustomEmojiId && MinBackgroundCustomEmojiBoostLevel > level)
{
feature = ChatBoostFeature.BackgroundCustomEmoji;
level = MinBackgroundCustomEmojiBoostLevel;
}

if (SelectedProfileAccentColor != null && SelectedProfileAccentColor.MinChannelChatBoostLevel > level)
if (profileAccentColorId != -1 && profileAccentColorId != chat.ProfileAccentColorId && SelectedProfileAccentColor.MinChannelChatBoostLevel > level)
{
feature = ChatBoostFeature.ProfileAccentColor;
level = SelectedProfileAccentColor.MinChannelChatBoostLevel;
}

if (SelectedProfileCustomEmojiId != 0 && MinProfileBackgroundCustomEmojiBoostLevel > level)
if (SelectedProfileCustomEmojiId != 0 && SelectedProfileCustomEmojiId != chat.ProfileBackgroundCustomEmojiId && MinProfileBackgroundCustomEmojiBoostLevel > level)
{
feature = ChatBoostFeature.ProfileBackgroundCustomEmoji;
level = MinProfileBackgroundCustomEmojiBoostLevel;
}

if (SelectedEmojiStatus != null && MinEmojiStatusBoostLevel > level)
if (SelectedEmojiStatus != null && SelectedEmojiStatus?.CustomEmojiId != chat.EmojiStatus?.CustomEmojiId && MinEmojiStatusBoostLevel > level)
{
feature = ChatBoostFeature.EmojiStatus;
level = MinEmojiStatusBoostLevel;
}

if (SelectedCustomEmojiStickerSet != 0 && MinCustomEmojiStickerSetBoostLevel > level)
if (ClientService.TryGetSupergroupFull(chat, out SupergroupFullInfo fullInfo))
{
feature = ChatBoostFeature.CustomEmojiStickerSet;
level = MinCustomEmojiStickerSetBoostLevel;
if (SelectedCustomEmojiStickerSet != 0 && SelectedCustomEmojiStickerSet != fullInfo.CustomEmojiStickerSetId && MinCustomEmojiStickerSetBoostLevel > level)
{
feature = ChatBoostFeature.CustomEmojiStickerSet;
level = MinCustomEmojiStickerSetBoostLevel;
}
}

if (SelectedChatTheme?.DarkSettings != null && MinChatThemeBackgroundBoostLevel > level)
var prevChatTheme = chat.Background?.Background.Type is BackgroundTypeChatTheme typeChatTheme
? typeChatTheme.ThemeName
: chat.ThemeName;

var nextChatTheme = SelectedChatTheme?.LightSettings != null
? SelectedChatTheme.Name
: string.Empty;

if (nextChatTheme.Length > 0 && prevChatTheme != nextChatTheme && MinChatThemeBackgroundBoostLevel > level)
{
feature = ChatBoostFeature.ChatTheme;
level = MinChatThemeBackgroundBoostLevel;
Expand Down

0 comments on commit 48eda05

Please sign in to comment.