fix toggling of ai instance discord properties
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import {Options, Vue} from 'vue-class-component';
|
||||
import {Prop} from "vue-property-decorator";
|
||||
import {getCurrentInstance} from "vue";
|
||||
import {toast} from "vue3-toastify";
|
||||
import {AiInstanceVmV1} from 'ai-oas';
|
||||
import {Prop} from 'vue-property-decorator';
|
||||
import {getCurrentInstance} from 'vue';
|
||||
import {toast} from 'vue3-toastify';
|
||||
import {AiInstanceVmV1, DiscordOnlineVmV1, DiscordReactoToChatVmV1} from 'ai-oas';
|
||||
import {ApiStore} from '@/stores/ApiStore';
|
||||
|
||||
@Options({
|
||||
@@ -23,10 +23,12 @@ export default class Discord extends Vue {
|
||||
set online(val: boolean) {
|
||||
const oldVal = this.online;
|
||||
this.aiInstance.discord.online = val;
|
||||
this.apiStore.aiApi.discordOnline(this.aiInstance.configuration.id, val).catch(e => {
|
||||
toast.error('Error while set online status: ' + JSON.stringify(e));
|
||||
this.aiInstance.discord.online = oldVal;
|
||||
});
|
||||
this.apiStore.aiApi
|
||||
.discordOnline(this.aiInstance.configuration.id, DiscordOnlineVmV1.fromJson({online: val}))
|
||||
.catch(e => {
|
||||
toast.error('Error while set online status: ' + JSON.stringify(e));
|
||||
this.aiInstance.discord.online = oldVal;
|
||||
});
|
||||
}
|
||||
|
||||
get reactToChat(): boolean {
|
||||
@@ -36,14 +38,16 @@ export default class Discord extends Vue {
|
||||
set reactToChat(val: boolean) {
|
||||
const oldVal = this.online;
|
||||
this.aiInstance.discord.reactToChat = val;
|
||||
this.apiStore.aiApi.discordReactToChat(this.aiInstance.configuration.name, val).catch(e => {
|
||||
toast.error('Error while setting react_to_chat status: ' + JSON.stringify(e));
|
||||
this.aiInstance.discord.reactToChat = oldVal;
|
||||
});
|
||||
this.apiStore.aiApi
|
||||
.discordReactToChat(this.aiInstance.configuration.id, DiscordReactoToChatVmV1.fromJson({reactToChat: val}))
|
||||
.catch(e => {
|
||||
toast.error('Error while setting react_to_chat status: ' + JSON.stringify(e));
|
||||
this.aiInstance.discord.reactToChat = oldVal;
|
||||
});
|
||||
}
|
||||
|
||||
get uid(): string {
|
||||
return "" + getCurrentInstance()?.uid!;
|
||||
return '' + getCurrentInstance()?.uid!;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user