Skip to content

Commit fc0fbde

Browse files
committed
fix(frontend): correctly create command when command list is empty
[skip-docker]
1 parent 7752230 commit fc0fbde

File tree

101 files changed

+19
-8710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+19
-8710
lines changed

apps/frontend/src/components/Command.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ const consoleLog = console.log;
120120
</script>
121121

122122
<template>
123-
<div class="p-4">
123+
<div
124+
v-if="command"
125+
class="p-4"
126+
>
124127
<Form
125128
v-slot="{ errors }"
126129
:validation-schema="schema"

apps/frontend/src/dashboard/Commands.vue

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ import { selectedDashboardStore } from '@/stores/userStore';
1616
const title = useTitle();
1717
title.value = 'Tsuwari - Commands';
1818
19-
type CommandType = UpdateOrCreateCommandDto
19+
type CommandType = UpdateOrCreateCommandDto & { new?: boolean }
2020
2121
const selectedDashboard = useStore(selectedDashboardStore);
2222
2323
const { execute, data: axiosData } = useAxios(`/v1/channels/${selectedDashboard.value.channelId}/commands`, api, { immediate: false });
2424
2525
const commands = ref<CommandType[]>([]);
2626
const variablesList = ref<VariablesList>([]);
27-
const currentEditableCommand = ref<CommandType>({} as any);
27+
const currentEditableCommand = ref<CommandType | null>(null);
2828
const searchFilter = ref<string>('');
2929
const filteredCommands = computed(() => {
30-
return commands.value.filter(c => searchFilter.value ? [c.name, ...c.aliases as string[]].some(s => s.includes(searchFilter.value)) : true).sort((a, b) => a.name.localeCompare(b.name));
30+
return commands.value.filter(c => c.name).filter(c => searchFilter.value ? [c.name, ...c.aliases as string[]].some(s => s.includes(searchFilter.value)) : true).sort((a, b) => a.name.localeCompare(b.name));
3131
});
3232
3333
watch(axiosData, (v: CommandType[]) => {
@@ -49,7 +49,7 @@ selectedDashboardStore.subscribe(async (v) => {
4949
});
5050
5151
function insertCommand() {
52-
if (commands.value && currentEditableCommand.value.id) {
52+
if (commands.value && !currentEditableCommand.value?.new) {
5353
const command: CommandType = {
5454
name: '',
5555
aliases: [],
@@ -60,10 +60,11 @@ function insertCommand() {
6060
enabled: true,
6161
responses: [],
6262
cooldownType: 'GLOBAL',
63+
new: true,
6364
};
6465
65-
currentEditableCommand.value = command;
6666
commands.value.unshift(command);
67+
currentEditableCommand.value = command;
6768
}
6869
}
6970
@@ -116,9 +117,9 @@ function onSave(index: number) {
116117
v-for="command, index of filteredCommands
117118
"
118119
:key="index"
119-
:class="{ 'border-l-2': filteredCommands.indexOf(currentEditableCommand) === index }"
120+
:class="{ 'border-l-2': filteredCommands.indexOf(currentEditableCommand!) === index }"
120121
@click="() => {
121-
if (!currentEditableCommand.id) commands.splice(commands.indexOf(currentEditableCommand), 1)
122+
if (!currentEditableCommand!.id) commands.splice(commands.indexOf(currentEditableCommand!), 1)
122123
currentEditableCommand = command
123124
}"
124125
>
@@ -127,7 +128,7 @@ function onSave(index: number) {
127128
href="/dashboard/commands"
128129
class="flex items-center mt-0 text-sm px-2 h-8 w-full overflow-hidden text-white text-ellipsis whitespace-nowrap hover:bg-[#202122] border-slate-300 transition duration-300 ease-in-out ripple-surface-primary"
129130
:class="{
130-
'bg-neutral-700': filteredCommands.indexOf(currentEditableCommand) === index
131+
'bg-neutral-700': filteredCommands.indexOf(currentEditableCommand!) === index
131132
}"
132133
>
133134
<span class="w-3 h-3" /><span>{{ command.name }}</span>
@@ -137,7 +138,10 @@ function onSave(index: number) {
137138
</div>
138139
</div>
139140

140-
<div class="w-full p-1 hidden sm:block h-fit m-4 block max-w-2xl rounded-lg card text-white shadow-lg">
141+
<div
142+
v-if="currentEditableCommand"
143+
class="w-full p-1 hidden sm:block h-fit m-4 block max-w-2xl rounded-lg card text-white shadow-lg"
144+
>
141145
<Command
142146
:command="currentEditableCommand"
143147
:commands="commands"

apps/frontend_daisy/.gitignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

apps/frontend_daisy/index.html

Lines changed: 0 additions & 35 deletions
This file was deleted.

apps/frontend_daisy/package.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)