Make emit typing safe

old-stable24
Varun Patil 2022-10-11 13:32:24 -07:00
parent 517aa727df
commit 795d0b5896
6 changed files with 26 additions and 24 deletions

View File

@ -100,7 +100,7 @@
</template>
<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator';
import { Component, Emit, Mixins } from 'vue-property-decorator';
import GlobalMixin from '../mixins/GlobalMixin';
import { IPhoto } from '../types';
@ -123,6 +123,8 @@ const EDIT_API_URL = '/apps/memories/api/edit/{id}';
}
})
export default class EditDate extends Mixins(GlobalMixin) {
@Emit('refresh') emitRefresh(val: boolean) {}
private photos: IPhoto[] = [];
private photosDone: number = 0;
private processing: boolean = false;
@ -236,7 +238,7 @@ export default class EditDate extends Mixins(GlobalMixin) {
const res = await axios.patch<any>(generateUrl(EDIT_API_URL, { id: this.photos[0].fileid }), {
date: this.getExifFormat(this.getDate()),
});
this.$emit('refresh', true);
this.emitRefresh(true);
this.close();
} catch (e) {
if (e.response?.data?.message) {
@ -314,7 +316,7 @@ export default class EditDate extends Mixins(GlobalMixin) {
// nothing to do
}
this.processing = false;
this.$emit('refresh', true);
this.emitRefresh(true);
this.close();
}

View File

@ -15,7 +15,7 @@
</template>
<script lang="ts">
import { Component, Mixins, Watch } from 'vue-property-decorator';
import { Component, Emit, Mixins, Watch } from 'vue-property-decorator';
import { NcButton, NcTextField } from '@nextcloud/vue';
import { showError } from '@nextcloud/dialogs'
import Modal from './Modal.vue';
@ -33,6 +33,9 @@ export default class FaceDeleteModal extends Mixins(GlobalMixin) {
private user: string = "";
private name: string = "";
@Emit('close')
public close() {}
@Watch('$route')
async routeChange(from: any, to: any) {
this.refreshParams();
@ -59,9 +62,5 @@ export default class FaceDeleteModal extends Mixins(GlobalMixin) {
}));
}
}
public close() {
this.$emit('close');
}
}
</script>

View File

@ -21,7 +21,7 @@
</template>
<script lang="ts">
import { Component, Mixins, Watch } from 'vue-property-decorator';
import { Component, Emit, Mixins, Watch } from 'vue-property-decorator';
import { NcButton, NcTextField } from '@nextcloud/vue';
import { showError } from '@nextcloud/dialogs'
import Modal from './Modal.vue';
@ -40,6 +40,9 @@ export default class FaceEditModal extends Mixins(GlobalMixin) {
private name: string = "";
private oldName: string = "";
@Emit('close')
public close() {}
@Watch('$route')
async routeChange(from: any, to: any) {
this.refreshParams();
@ -71,10 +74,6 @@ export default class FaceEditModal extends Mixins(GlobalMixin) {
}));
}
}
public close() {
this.$emit('close');
}
}
</script>

View File

@ -26,7 +26,7 @@
</template>
<script lang="ts">
import { Component, Mixins, Watch } from 'vue-property-decorator';
import { Component, Emit, Mixins, Watch } from 'vue-property-decorator';
import { NcButton, NcTextField } from '@nextcloud/vue';
import { showError } from '@nextcloud/dialogs'
import { IFileInfo, IPhoto, ITag } from '../types';
@ -52,6 +52,9 @@ export default class FaceMergeModal extends Mixins(GlobalMixin) {
private processing = 0;
private procesingTotal = 0;
@Emit('close')
public close() {}
@Watch('$route')
async routeChange(from: any, to: any) {
this.refreshParams();
@ -137,10 +140,6 @@ export default class FaceMergeModal extends Mixins(GlobalMixin) {
}));
}
}
public close() {
this.$emit('close');
}
}
</script>

View File

@ -1,7 +1,7 @@
<template>
<NcModal
:size="size"
@close="$emit('close')"
@close="close"
:outTransition="true">
<div class="container">
<div class="head">
@ -18,7 +18,7 @@
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { Component, Emit, Prop, Vue } from 'vue-property-decorator';
import { NcModal } from '@nextcloud/vue';
@Component({
@ -28,6 +28,9 @@ import { NcModal } from '@nextcloud/vue';
})
export default class Modal extends Vue {
@Prop({default: 'small'}) private size?: string;
@Emit('close')
public close() {}
}
</script>

View File

@ -5,7 +5,7 @@
hasError: error,
isFace: isFace,
}"
@click="openTag()"
@click="openTag(data)"
v-bind:style="{
width: rowHeight + 'px',
height: rowHeight + 'px',
@ -32,7 +32,7 @@
</template>
<script lang="ts">
import { Component, Prop, Watch, Mixins } from 'vue-property-decorator';
import { Component, Prop, Watch, Mixins, Emit } from 'vue-property-decorator';
import { IPhoto, ITag } from '../types';
import { generateUrl } from '@nextcloud/router'
import { getPreviewUrl } from "../services/FileUtils";
@ -112,8 +112,8 @@ export default class Tag extends Mixins(GlobalMixin) {
}
/** Open tag */
openTag() {
this.$emit('open', this.data);
@Emit('open')
openTag(tag: ITag) {
if (this.noNavigate) {
return;
}