Skip to content

Commit

Permalink
kruto
Browse files Browse the repository at this point in the history
  • Loading branch information
Satont committed Jun 10, 2024
1 parent a78391c commit 0841d34
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 7 deletions.
26 changes: 20 additions & 6 deletions apps/api-gql/internal/gql/resolvers/overlays.resolver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 108 additions & 0 deletions apps/api-gql/internal/gql/resolvers/overlays.resolver.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,111 @@ func (r *mutationResolver) updateChatOverlay(

return true, nil
}

func (r *mutationResolver) chatOverlayCreate(
ctx context.Context,
opts gqlmodel.ChatOverlayMutateOpts,
) (bool, error) {
dashboardId, err := r.sessions.GetSelectedDashboard(ctx)
if err != nil {
return false, err
}

entity := model.ChatOverlaySettings{
ID: uuid.UUID{},
ChannelID: dashboardId,
}

if opts.MessageHideTimeout.IsSet() {
entity.MessageHideTimeout = uint32(*opts.MessageHideTimeout.Value())
}

if opts.MessageShowDelay.IsSet() {
entity.MessageShowDelay = uint32(*opts.MessageShowDelay.Value())
}

if opts.Preset.IsSet() {
entity.Preset = *opts.Preset.Value()
}

if opts.FontSize.IsSet() {
entity.FontSize = uint32(*opts.FontSize.Value())
}

if opts.HideCommands.IsSet() {
entity.HideCommands = *opts.HideCommands.Value()
}

if opts.HideBots.IsSet() {
entity.HideBots = *opts.HideBots.Value()
}

if opts.FontFamily.IsSet() {
entity.FontFamily = *opts.FontFamily.Value()
}

if opts.ShowBadges.IsSet() {
entity.ShowBadges = *opts.ShowBadges.Value()
}

if opts.ShowAnnounceBadge.IsSet() {
entity.ShowAnnounceBadge = *opts.ShowAnnounceBadge.Value()
}

if opts.TextShadowColor.IsSet() {
entity.TextShadowColor = *opts.TextShadowColor.Value()
}

if opts.TextShadowSize.IsSet() {
entity.TextShadowSize = uint32(*opts.TextShadowSize.Value())
}

if opts.ChatBackgroundColor.IsSet() {
entity.ChatBackgroundColor = *opts.ChatBackgroundColor.Value()
}

if opts.Direction.IsSet() {
entity.Direction = *opts.Direction.Value()
}

if opts.FontWeight.IsSet() {
entity.FontWeight = uint32(*opts.FontWeight.Value())
}

if opts.FontStyle.IsSet() {
entity.FontStyle = *opts.FontStyle.Value()
}

if opts.PaddingContainer.IsSet() {
entity.PaddingContainer = uint32(*opts.PaddingContainer.Value())
}

if opts.Animation.IsSet() {
entity.Animation = model.ChatOverlaySettingsAnimationType(*opts.Animation.Value())
}

if err := r.gorm.
WithContext(ctx).
Create(&entity).Error; err != nil {
return false, fmt.Errorf("failed to create chat overlay settings: %w", err)
}

return true, nil
}

func (r *mutationResolver) chatOverlayDelete(ctx context.Context, id string) (bool, error) {
dashboardId, err := r.sessions.GetSelectedDashboard(ctx)
if err != nil {
return false, err
}

entity := model.ChatOverlaySettings{}
if err := r.gorm.
WithContext(ctx).
Where("channel_id = ? AND id = ?", dashboardId, id).
Delete(&entity).Error; err != nil {
return false, fmt.Errorf("failed to delete chat overlay settings: %w", err)
}

return true, nil
}
2 changes: 1 addition & 1 deletion frontend/dashboard/src/pages/overlays/chat/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const addable = computed(() => {
</NTabPane>
</template>
</NTabs>
<NAlert v-if="!chatOverlaysData?.chatOverlays" type="info" class="mt-2">
<NAlert v-if="!chatOverlaysData?.chatOverlays.length" type="info" class="mt-2">
Create new overlay for edit settings
</NAlert>
</div>
Expand Down

0 comments on commit 0841d34

Please sign in to comment.