Make emit typing safe

cache
Varun Patil 2022-10-11 13:32:24 -07:00
parent e3724e32dc
commit 91e8dd326b
6 changed files with 26 additions and 24 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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