* fix: emits use ev instead of e

* fix: errors use err instead of e

* fix: replace use of data where possible

* fix: events use evt instead of e

* fix: use strict equals

* fix: use emoji instead of e

* fix: vue lints
This commit is contained in:
Johann150
2022-05-26 15:53:09 +02:00
committed by GitHub
parent 9c80403072
commit 3dae18b93c
69 changed files with 255 additions and 257 deletions

View File

@@ -90,14 +90,14 @@ export default defineComponent({
getAcct: Acct.toString,
isMe(message) {
return message.userId == this.$i.id;
return message.userId === this.$i.id;
},
onMessage(message) {
if (message.recipientId) {
this.messages = this.messages.filter(m => !(
(m.recipientId == message.recipientId && m.userId == message.userId) ||
(m.recipientId == message.userId && m.userId == message.recipientId)));
(m.recipientId === message.recipientId && m.userId === message.userId) ||
(m.recipientId === message.userId && m.userId === message.recipientId)));
this.messages.unshift(message);
} else if (message.groupId) {
@@ -108,7 +108,7 @@ export default defineComponent({
onRead(ids) {
for (const id of ids) {
const found = this.messages.find(m => m.id == id);
const found = this.messages.find(m => m.id === id);
if (found) {
if (found.recipientId) {
found.isRead = true;

View File

@@ -59,7 +59,7 @@ export default defineComponent({
return this.user ? 'user:' + this.user.id : 'group:' + this.group.id;
},
canSend(): boolean {
return (this.text != null && this.text != '') || this.file != null;
return (this.text != null && this.text !== '') || this.file != null;
},
room(): any {
return this.$parent;
@@ -88,12 +88,11 @@ export default defineComponent({
}
},
methods: {
async onPaste(e: ClipboardEvent) {
const data = e.clipboardData;
const items = data.items;
async onPaste(evt: ClipboardEvent) {
const items = evt.clipboardData.items;
if (items.length == 1) {
if (items[0].kind == 'file') {
if (items.length === 1) {
if (items[0].kind === 'file') {
const file = items[0].getAsFile();
const lio = file.name.lastIndexOf('.');
const ext = lio >= 0 ? file.name.slice(lio) : '';
@@ -101,7 +100,7 @@ export default defineComponent({
if (formatted) this.upload(file, formatted);
}
} else {
if (items[0].kind == 'file') {
if (items[0].kind === 'file') {
os.alert({
type: 'error',
text: this.$ts.onlyOneFileCanBeAttached
@@ -110,23 +109,23 @@ export default defineComponent({
}
},
onDragover(e) {
const isFile = e.dataTransfer.items[0].kind == 'file';
const isDriveFile = e.dataTransfer.types[0] == _DATA_TRANSFER_DRIVE_FILE_;
onDragover(evt) {
const isFile = evt.dataTransfer.items[0].kind === 'file';
const isDriveFile = evt.dataTransfer.types[0] === _DATA_TRANSFER_DRIVE_FILE_;
if (isFile || isDriveFile) {
e.preventDefault();
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed == 'all' ? 'copy' : 'move';
evt.preventDefault();
evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === 'all' ? 'copy' : 'move';
}
},
onDrop(e): void {
onDrop(evt): void {
// ファイルだったら
if (e.dataTransfer.files.length == 1) {
e.preventDefault();
this.upload(e.dataTransfer.files[0]);
if (evt.dataTransfer.files.length === 1) {
evt.preventDefault();
this.upload(evt.dataTransfer.files[0]);
return;
} else if (e.dataTransfer.files.length > 1) {
e.preventDefault();
} else if (evt.dataTransfer.files.length > 1) {
evt.preventDefault();
os.alert({
type: 'error',
text: this.$ts.onlyOneFileCanBeAttached
@@ -135,17 +134,17 @@ export default defineComponent({
}
//#region ドライブのファイル
const driveFile = e.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile != '') {
const driveFile = evt.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile !== '') {
this.file = JSON.parse(driveFile);
e.preventDefault();
evt.preventDefault();
}
//#endregion
},
onKeydown(e) {
onKeydown(evt) {
this.typing();
if ((e.which == 10 || e.which == 13) && (e.ctrlKey || e.metaKey) && this.canSend) {
if ((evt.which === 10 || evt.which === 13) && (evt.ctrlKey || evt.metaKey) && this.canSend) {
this.send();
}
},
@@ -154,8 +153,8 @@ export default defineComponent({
this.typing();
},
chooseFile(e) {
selectFile(e.currentTarget ?? e.target, this.$ts.selectFile).then(file => {
chooseFile(evt) {
selectFile(evt.currentTarget ?? evt.target, this.$ts.selectFile).then(file => {
this.file = file;
});
},
@@ -193,9 +192,9 @@ export default defineComponent({
},
saveDraft() {
const data = JSON.parse(localStorage.getItem('message_drafts') || '{}');
const drafts = JSON.parse(localStorage.getItem('message_drafts') || '{}');
data[this.draftKey] = {
drafts[this.draftKey] = {
updatedAt: new Date(),
data: {
text: this.text,
@@ -203,15 +202,15 @@ export default defineComponent({
}
}
localStorage.setItem('message_drafts', JSON.stringify(data));
localStorage.setItem('message_drafts', JSON.stringify(drafts));
},
deleteDraft() {
const data = JSON.parse(localStorage.getItem('message_drafts') || '{}');
const drafts = JSON.parse(localStorage.getItem('message_drafts') || '{}');
delete data[this.draftKey];
delete drafts[this.draftKey];
localStorage.setItem('message_drafts', JSON.stringify(data));
localStorage.setItem('message_drafts', JSON.stringify(drafts));
},
async insertEmoji(ev) {

View File

@@ -166,23 +166,23 @@ const Component = defineComponent({
});
},
onDragover(e) {
const isFile = e.dataTransfer.items[0].kind == 'file';
const isDriveFile = e.dataTransfer.types[0] == _DATA_TRANSFER_DRIVE_FILE_;
onDragover(evt) {
const isFile = evt.dataTransfer.items[0].kind === 'file';
const isDriveFile = evt.dataTransfer.types[0] === _DATA_TRANSFER_DRIVE_FILE_;
if (isFile || isDriveFile) {
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed == 'all' ? 'copy' : 'move';
evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === 'all' ? 'copy' : 'move';
} else {
e.dataTransfer.dropEffect = 'none';
evt.dataTransfer.dropEffect = 'none';
}
},
onDrop(e): void {
onDrop(evt): void {
// ファイルだったら
if (e.dataTransfer.files.length == 1) {
this.form.upload(e.dataTransfer.files[0]);
if (evt.dataTransfer.files.length === 1) {
this.form.upload(evt.dataTransfer.files[0]);
return;
} else if (e.dataTransfer.files.length > 1) {
} else if (evt.dataTransfer.files.length > 1) {
os.alert({
type: 'error',
text: this.$ts.onlyOneFileCanBeAttached
@@ -191,8 +191,8 @@ const Component = defineComponent({
}
//#region ドライブのファイル
const driveFile = e.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile != '') {
const driveFile = evt.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile !== '') {
const file = JSON.parse(driveFile);
this.form.file = file;
}
@@ -209,7 +209,7 @@ const Component = defineComponent({
limit: max + 1,
untilId: this.existMoreMessages ? this.messages[0].id : undefined
}).then(messages => {
if (messages.length == max + 1) {
if (messages.length === max + 1) {
this.existMoreMessages = true;
messages.pop();
} else {
@@ -235,7 +235,7 @@ const Component = defineComponent({
const _isBottom = isBottom(this.$el, 64);
this.messages.push(message);
if (message.userId != this.$i.id && !document.hidden) {
if (message.userId !== this.$i.id && !document.hidden) {
this.connection.send('read', {
id: message.id
});
@@ -246,7 +246,7 @@ const Component = defineComponent({
this.$nextTick(() => {
this.scrollToBottom();
});
} else if (message.userId != this.$i.id) {
} else if (message.userId !== this.$i.id) {
// Notify
this.notifyNewMessage();
}
@@ -256,7 +256,7 @@ const Component = defineComponent({
if (this.user) {
if (!Array.isArray(x)) x = [x];
for (const id of x) {
if (this.messages.some(x => x.id == id)) {
if (this.messages.some(x => x.id === id)) {
const exist = this.messages.map(x => x.id).indexOf(id);
this.messages[exist] = {
...this.messages[exist],
@@ -266,7 +266,7 @@ const Component = defineComponent({
}
} else if (this.group) {
for (const id of x.ids) {
if (this.messages.some(x => x.id == id)) {
if (this.messages.some(x => x.id === id)) {
const exist = this.messages.map(x => x.id).indexOf(id);
this.messages[exist] = {
...this.messages[exist],