@@ -16,18 +16,18 @@ import { selectedDashboardStore } from '@/stores/userStore';
16
16
const title = useTitle ();
17
17
title .value = ' Tsuwari - Commands' ;
18
18
19
- type CommandType = UpdateOrCreateCommandDto
19
+ type CommandType = UpdateOrCreateCommandDto & { new ? : boolean }
20
20
21
21
const selectedDashboard = useStore (selectedDashboardStore );
22
22
23
23
const { execute, data : axiosData } = useAxios (` /v1/channels/${selectedDashboard .value .channelId }/commands ` , api , { immediate: false });
24
24
25
25
const commands = ref <CommandType []>([]);
26
26
const variablesList = ref <VariablesList >([]);
27
- const currentEditableCommand = ref <CommandType >({} as any );
27
+ const currentEditableCommand = ref <CommandType | null >( null );
28
28
const searchFilter = ref <string >(' ' );
29
29
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 ));
31
31
});
32
32
33
33
watch (axiosData , (v : CommandType []) => {
@@ -49,7 +49,7 @@ selectedDashboardStore.subscribe(async (v) => {
49
49
});
50
50
51
51
function insertCommand() {
52
- if (commands .value && currentEditableCommand .value . id ) {
52
+ if (commands .value && ! currentEditableCommand .value ?. new ) {
53
53
const command: CommandType = {
54
54
name: ' ' ,
55
55
aliases: [],
@@ -60,10 +60,11 @@ function insertCommand() {
60
60
enabled: true ,
61
61
responses: [],
62
62
cooldownType: ' GLOBAL' ,
63
+ new: true ,
63
64
};
64
65
65
- currentEditableCommand .value = command ;
66
66
commands .value .unshift (command );
67
+ currentEditableCommand .value = command ;
67
68
}
68
69
}
69
70
@@ -116,9 +117,9 @@ function onSave(index: number) {
116
117
v-for =" command, index of filteredCommands
117
118
"
118
119
:key =" index"
119
- :class =" { 'border-l-2': filteredCommands.indexOf(currentEditableCommand) === index }"
120
+ :class =" { 'border-l-2': filteredCommands.indexOf(currentEditableCommand! ) === index }"
120
121
@click =" () => {
121
- if (!currentEditableCommand.id) commands.splice(commands.indexOf(currentEditableCommand), 1)
122
+ if (!currentEditableCommand! .id) commands.splice(commands.indexOf(currentEditableCommand! ), 1)
122
123
currentEditableCommand = command
123
124
}"
124
125
>
@@ -127,7 +128,7 @@ function onSave(index: number) {
127
128
href =" /dashboard/commands"
128
129
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"
129
130
:class =" {
130
- 'bg-neutral-700': filteredCommands.indexOf(currentEditableCommand) === index
131
+ 'bg-neutral-700': filteredCommands.indexOf(currentEditableCommand! ) === index
131
132
}"
132
133
>
133
134
<span class =" w-3 h-3" /><span >{{ command.name }}</span >
@@ -137,7 +138,10 @@ function onSave(index: number) {
137
138
</div >
138
139
</div >
139
140
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
+ >
141
145
<Command
142
146
:command =" currentEditableCommand"
143
147
:commands =" commands"
0 commit comments