From 125849673a1aba46021852ee473d00f4520d1bd6 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Tue, 11 Dec 2018 20:36:55 +0900 Subject: [PATCH] Use for-of instead of forEach (#3583) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: syuilo Co-authored-by: Acid Chicken (硫酸鶏) --- src/chart/index.ts | 8 +-- src/client/app/admin/views/ap-log.vue | 4 +- src/client/app/admin/views/cpu-memory.vue | 4 +- src/client/app/admin/views/dashboard.vue | 4 +- src/client/app/admin/views/emoji.vue | 4 +- src/client/app/boot.js | 6 +- src/client/app/common/define-widget.ts | 11 ++- src/client/app/common/hotkey.ts | 6 +- .../app/common/scripts/check-for-update.ts | 7 +- src/client/app/common/scripts/stream.ts | 4 +- .../common/views/components/autocomplete.vue | 32 ++++----- .../common/views/components/emoji-picker.vue | 4 +- .../components/games/reversi/reversi.game.vue | 8 +-- .../views/components/messaging-room.vue | 8 +-- .../app/common/views/components/messaging.vue | 4 +- .../app/common/views/components/poll.vue | 4 +- .../common/views/widgets/posts-monitor.vue | 2 +- .../views/widgets/server.cpu-memory.vue | 2 +- .../views/components/activity.calendar.vue | 4 +- .../views/components/activity.chart.vue | 5 +- .../desktop/views/components/context-menu.vue | 8 +-- .../desktop/views/components/drive.folder.vue | 4 +- .../views/components/drive.nav-folder.vue | 4 +- .../app/desktop/views/components/drive.vue | 14 ++-- .../views/components/emoji-picker-dialog.vue | 8 +-- .../app/desktop/views/components/home.vue | 12 ++-- .../app/desktop/views/components/notes.vue | 4 +- .../desktop/views/components/post-form.vue | 15 ++-- .../views/components/timeline.core.vue | 4 +- .../views/components/ui.header.account.vue | 8 +-- .../components/ui.header.notifications.vue | 8 +-- .../desktop/views/components/ui.sidebar.vue | 8 +-- .../views/components/user-list-timeline.vue | 2 +- .../app/desktop/views/components/window.vue | 6 +- .../desktop/views/pages/deck/deck.column.vue | 4 +- .../desktop/views/pages/deck/deck.direct.vue | 4 +- .../views/pages/deck/deck.hashtag-tl.vue | 4 +- .../desktop/views/pages/deck/deck.list-tl.vue | 4 +- .../views/pages/deck/deck.mentions.vue | 4 +- .../desktop/views/pages/deck/deck.notes.vue | 4 +- .../views/pages/deck/deck.notifications.vue | 4 +- .../app/desktop/views/pages/deck/deck.tl.vue | 4 +- .../views/pages/deck/deck.user-column.vue | 10 +-- src/client/app/desktop/views/pages/search.vue | 4 +- src/client/app/desktop/views/pages/tag.vue | 4 +- .../desktop/views/pages/user/user.photos.vue | 8 +-- .../views/pages/user/user.timeline.vue | 4 +- .../app/desktop/views/widgets/post-form.vue | 10 +-- .../app/mobile/views/components/drive.vue | 11 +-- .../app/mobile/views/components/notes.vue | 4 +- .../app/mobile/views/components/post-form.vue | 8 +-- .../views/components/user-list-timeline.vue | 4 +- .../mobile/views/components/user-timeline.vue | 4 +- .../app/mobile/views/pages/home.timeline.vue | 4 +- src/client/app/mobile/views/pages/search.vue | 4 +- src/client/app/mobile/views/pages/tag.vue | 4 +- .../mobile/views/pages/user/home.photos.vue | 18 ++--- src/client/app/store.ts | 18 ++--- src/client/app/sw.js | 4 +- src/client/app/theme.ts | 11 ++- src/mfm/html-to-mfm.ts | 12 +++- src/mfm/parse.ts | 15 ++-- src/prelude/array.ts | 4 ++ src/push-sw.ts | 4 +- .../api/endpoints/aggregation/hashtags.ts | 7 +- .../api/endpoints/drive/files/update.ts | 4 +- .../api/endpoints/games/reversi/games/show.ts | 3 +- src/server/api/endpoints/hashtags/trend.ts | 7 +- src/server/api/endpoints/i/update_widget.ts | 10 +-- src/server/api/endpoints/notes/mentions.ts | 4 +- src/server/api/endpoints/notes/polls/vote.ts | 4 +- .../users/get_frequently_replied_users.ts | 11 ++- src/server/api/index.ts | 11 +-- .../api/stream/channels/games/reversi-game.ts | 4 +- src/server/api/stream/index.ts | 6 +- src/server/index.ts | 4 +- src/server/web/docs.ts | 12 ++-- src/services/following/requests/accept-all.ts | 4 +- src/services/i/pin.ts | 4 +- src/services/i/update.ts | 4 +- src/services/note/create.ts | 72 +++++++++---------- src/services/note/delete.ts | 12 ++-- src/services/note/reaction/create.ts | 4 +- tslint.json | 4 ++ 84 files changed, 345 insertions(+), 283 deletions(-) diff --git a/src/chart/index.ts b/src/chart/index.ts index fa9f4c2eb9..ccfcef39ab 100644 --- a/src/chart/index.ts +++ b/src/chart/index.ts @@ -74,14 +74,14 @@ export default abstract class Chart { const query: Obj = {}; const dive = (x: Obj, path: string) => { - Object.entries(x).forEach(([k, v]) => { + for (const [k, v] of Object.entries(x)) { const p = path ? `${path}.${k}` : k; if (typeof v === 'number') { query[p] = v; } else { dive(v, p); } - }); + } }; dive(x, path); @@ -334,14 +334,14 @@ export default abstract class Chart { * にする */ const dive = (x: Obj, path?: string) => { - Object.entries(x).forEach(([k, v]) => { + for (const [k, v] of Object.entries(x)) { const p = path ? `${path}.${k}` : k; if (typeof v == 'object') { dive(v, p); } else { nestedProperty.set(res, p, chart.map(s => nestedProperty.get(s, p))); } - }); + } }; dive(chart[0]); diff --git a/src/client/app/admin/views/ap-log.vue b/src/client/app/admin/views/ap-log.vue index 1524340ecb..be665656a2 100644 --- a/src/client/app/admin/views/ap-log.vue +++ b/src/client/app/admin/views/ap-log.vue @@ -56,7 +56,9 @@ export default Vue.extend({ }, onLogs(logs) { - logs.reverse().forEach(log => this.onLog(log)); + for (const log of logs.reverse()) { + this.onLog(log) + } } } }); diff --git a/src/client/app/admin/views/cpu-memory.vue b/src/client/app/admin/views/cpu-memory.vue index a111dfe32d..a8237fe411 100644 --- a/src/client/app/admin/views/cpu-memory.vue +++ b/src/client/app/admin/views/cpu-memory.vue @@ -132,7 +132,9 @@ export default Vue.extend({ }, onStatsLog(statsLog) { - statsLog.reverse().forEach(stats => this.onStats(stats)); + for (const stats of statsLog.reverse()) { + this.onStats(stats); + } } } }); diff --git a/src/client/app/admin/views/dashboard.vue b/src/client/app/admin/views/dashboard.vue index 3fd024a133..9fb97f2ef9 100644 --- a/src/client/app/admin/views/dashboard.vue +++ b/src/client/app/admin/views/dashboard.vue @@ -127,12 +127,12 @@ export default Vue.extend({ this.$root.api('instances', { sort: '+notes' }).then(instances => { - instances.forEach(i => { + for (const i of instances) { i.bg = randomColor({ seed: i.host, luminosity: 'dark' }); - }); + } this.instances = instances; }); }, diff --git a/src/client/app/admin/views/emoji.vue b/src/client/app/admin/views/emoji.vue index 0819a07546..cf0f643209 100644 --- a/src/client/app/admin/views/emoji.vue +++ b/src/client/app/admin/views/emoji.vue @@ -91,7 +91,9 @@ export default Vue.extend({ fetchEmojis() { this.$root.api('admin/emoji/list').then(emojis => { emojis.reverse(); - emojis.forEach(e => e.aliases = (e.aliases || []).join(' ')); + for (const e of emojis) { + e.aliases = (e.aliases || []).join(' '); + } this.emojis = emojis; }); }, diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 5e894a18d7..4e9d3192c7 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -17,9 +17,9 @@ //#region Apply theme const theme = localStorage.getItem('theme'); if (theme) { - Object.entries(JSON.parse(theme)).forEach(([k, v]) => { + for (const [k, v] of Object.entries(JSON.parse(theme))) { document.documentElement.style.setProperty(`--${k}`, v.toString()); - }); + } } //#endregion @@ -160,7 +160,7 @@ navigator.serviceWorker.controller.postMessage('clear'); navigator.serviceWorker.getRegistrations().then(registrations => { - registrations.forEach(registration => registration.unregister()); + for (const registration of registrations) registration.unregister(); }); } catch (e) { console.error(e); diff --git a/src/client/app/common/define-widget.ts b/src/client/app/common/define-widget.ts index 56314a4104..5eb9718446 100644 --- a/src/client/app/common/define-widget.ts +++ b/src/client/app/common/define-widget.ts @@ -1,6 +1,6 @@ import Vue from 'vue'; -export default function(data: { +export default function (data: { name: string; props?: () => T; }) { @@ -53,11 +53,10 @@ export default function(data: { mergeProps() { if (data.props) { const defaultProps = data.props(); - Object.keys(defaultProps).forEach(prop => { - if (!this.props.hasOwnProperty(prop)) { - Vue.set(this.props, prop, defaultProps[prop]); - } - }); + for (const prop of Object.keys(defaultProps)) { + if (this.props.hasOwnProperty(prop)) continue; + Vue.set(this.props, prop, defaultProps[prop]); + } } }, diff --git a/src/client/app/common/hotkey.ts b/src/client/app/common/hotkey.ts index 28a5ec204d..b2afd57ae3 100644 --- a/src/client/app/common/hotkey.ts +++ b/src/client/app/common/hotkey.ts @@ -28,15 +28,15 @@ const getKeyMap = keymap => Object.entries(keymap).map(([patterns, callback]): a shift: false } as pattern; - part.trim().split('+').forEach(key => { - key = key.trim().toLowerCase(); + const keys = part.trim().split('+').map(x => x.trim().toLowerCase()); + for (const key of keys) { switch (key) { case 'ctrl': pattern.ctrl = true; break; case 'alt': pattern.alt = true; break; case 'shift': pattern.shift = true; break; default: pattern.which = keyCode(key).map(k => k.toLowerCase()); } - }); + } return pattern; }); diff --git a/src/client/app/common/scripts/check-for-update.ts b/src/client/app/common/scripts/check-for-update.ts index e8a5d18f09..20da83a0c2 100644 --- a/src/client/app/common/scripts/check-for-update.ts +++ b/src/client/app/common/scripts/check-for-update.ts @@ -14,9 +14,10 @@ export default async function($root: any, force = false, silent = false) { navigator.serviceWorker.controller.postMessage('clear'); } - navigator.serviceWorker.getRegistrations().then(registrations => { - registrations.forEach(registration => registration.unregister()); - }); + const registrations = await navigator.serviceWorker.getRegistrations(); + for (const registration of registrations) { + registration.unregister(); + } } catch (e) { console.error(e); } diff --git a/src/client/app/common/scripts/stream.ts b/src/client/app/common/scripts/stream.ts index 80278a76f6..23f839ae85 100644 --- a/src/client/app/common/scripts/stream.ts +++ b/src/client/app/common/scripts/stream.ts @@ -111,9 +111,9 @@ export default class Stream extends EventEmitter { connections = [this.nonSharedConnections.find(c => c.id === id)]; } - connections.filter(c => c != null).forEach(c => { + for (const c of connections.filter(c => c != null)) { c.emit(body.type, body.body); - }); + } } else { this.emit(type, body); } diff --git a/src/client/app/common/views/components/autocomplete.vue b/src/client/app/common/views/components/autocomplete.vue index 1d860ff545..e33e4ae8c5 100644 --- a/src/client/app/common/views/components/autocomplete.vue +++ b/src/client/app/common/views/components/autocomplete.vue @@ -57,18 +57,18 @@ const emjdb: EmojiDef[] = lib.map((x: any) => ({ url: `https://twemoji.maxcdn.com/2/svg/${char2file(x[1].char)}.svg` })); -lib.forEach((x: any) => { +for (const x of lib as any) { if (x[1].keywords) { - x[1].keywords.forEach(k => { + for (const k of x[1].keywords) { emjdb.push({ emoji: x[1].char, name: k, aliasOf: x[0], url: `https://twemoji.maxcdn.com/2/svg/${char2file(x[1].char)}.svg` }); - }); + } } -}); +} emjdb.sort((a, b) => a.name.length - b.name.length); @@ -120,7 +120,7 @@ export default Vue.extend({ const customEmojis = (this.$root.getMetaSync() || { emojis: [] }).emojis || []; const emojiDefinitions: EmojiDef[] = []; - customEmojis.forEach(x => { + for (const x of customEmojis) { emojiDefinitions.push({ name: x.name, emoji: `:${x.name}:`, @@ -129,7 +129,7 @@ export default Vue.extend({ }); if (x.aliases) { - x.aliases.forEach(alias => { + for (const alias of x.aliases) { emojiDefinitions.push({ name: alias, aliasOf: x.name, @@ -137,9 +137,9 @@ export default Vue.extend({ url: x.url, isCustomEmoji: true }); - }); + } } - }); + } emojiDefinitions.sort((a, b) => a.name.length - b.name.length); @@ -148,9 +148,9 @@ export default Vue.extend({ this.textarea.addEventListener('keydown', this.onKeydown); - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.addEventListener('mousedown', this.onMousedown); - }); + } this.$nextTick(() => { this.exec(); @@ -166,18 +166,18 @@ export default Vue.extend({ beforeDestroy() { this.textarea.removeEventListener('keydown', this.onKeydown); - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.removeEventListener('mousedown', this.onMousedown); - }); + } }, methods: { exec() { this.select = -1; if (this.$refs.suggests) { - Array.from(this.items).forEach(el => { + for (const el of Array.from(this.items)) { el.removeAttribute('data-selected'); - }); + } } if (this.type == 'user') { @@ -316,9 +316,9 @@ export default Vue.extend({ }, applySelect() { - Array.from(this.items).forEach(el => { + for (const el of Array.from(this.items)) { el.removeAttribute('data-selected'); - }); + } this.items[this.select].setAttribute('data-selected', 'true'); (this.items[this.select] as any).focus(); diff --git a/src/client/app/common/views/components/emoji-picker.vue b/src/client/app/common/views/components/emoji-picker.vue index 8181047167..f9164ad524 100644 --- a/src/client/app/common/views/components/emoji-picker.vue +++ b/src/client/app/common/views/components/emoji-picker.vue @@ -114,11 +114,11 @@ export default Vue.extend({ }, onScroll(e) { - const section = this.categories.forEach(x => { + for (const x of this.categories) { const top = e.target.scrollTop; const el = this.$refs[x.ref][0]; x.isActive = el.offsetTop <= top && el.offsetTop + el.offsetHeight > top; - }); + } }, chosen(emoji) { diff --git a/src/client/app/common/views/components/games/reversi/reversi.game.vue b/src/client/app/common/views/components/games/reversi/reversi.game.vue index c5619f9058..6d13b34c32 100644 --- a/src/client/app/common/views/components/games/reversi/reversi.game.vue +++ b/src/client/app/common/views/components/games/reversi/reversi.game.vue @@ -185,9 +185,9 @@ export default Vue.extend({ loopedBoard: this.game.settings.loopedBoard }); - this.game.logs.forEach(log => { + for (const log of this.game.logs) { this.o.put(log.color, log.pos); - }); + } this.logs = this.game.logs; this.logPos = this.logs.length; @@ -287,9 +287,9 @@ export default Vue.extend({ loopedBoard: this.game.settings.loopedBoard }); - this.game.logs.forEach(log => { + for (const log of this.game.logs) { this.o.put(log.color, log.pos, true); - }); + } this.logs = this.game.logs; this.logPos = this.logs.length; diff --git a/src/client/app/common/views/components/messaging-room.vue b/src/client/app/common/views/components/messaging-room.vue index b6132ceeb0..29aacd3bae 100644 --- a/src/client/app/common/views/components/messaging-room.vue +++ b/src/client/app/common/views/components/messaging-room.vue @@ -196,12 +196,12 @@ export default Vue.extend({ onRead(ids) { if (!Array.isArray(ids)) ids = [ids]; - ids.forEach(id => { + for (const id of ids) { if (this.messages.some(x => x.id == id)) { const exist = this.messages.map(x => x.id).indexOf(id); this.messages[exist].isRead = true; } - }); + } }, isBottom() { @@ -248,13 +248,13 @@ export default Vue.extend({ onVisibilitychange() { if (document.hidden) return; - this.messages.forEach(message => { + for (const message of this.messages) { if (message.userId !== this.$store.state.i.id && !message.isRead) { this.connection.send('read', { id: message.id }); } - }); + } } } }); diff --git a/src/client/app/common/views/components/messaging.vue b/src/client/app/common/views/components/messaging.vue index f8d0623b99..9683ca0ca3 100644 --- a/src/client/app/common/views/components/messaging.vue +++ b/src/client/app/common/views/components/messaging.vue @@ -103,10 +103,10 @@ export default Vue.extend({ this.messages.unshift(message); }, onRead(ids) { - ids.forEach(id => { + for (const id of ids) { const found = this.messages.find(m => m.id == id); if (found) found.isRead = true; - }); + } }, search() { if (this.q == '') { diff --git a/src/client/app/common/views/components/poll.vue b/src/client/app/common/views/components/poll.vue index 8a31ec83d7..8817d88cc5 100644 --- a/src/client/app/common/views/components/poll.vue +++ b/src/client/app/common/views/components/poll.vue @@ -55,12 +55,12 @@ export default Vue.extend({ noteId: this.note.id, choice: id }).then(() => { - this.poll.choices.forEach(c => { + for (const c of this.poll.choices) { if (c.id == id) { c.votes++; Vue.set(c, 'isVoted', true); } - }); + } this.showResult = true; }); } diff --git a/src/client/app/common/views/widgets/posts-monitor.vue b/src/client/app/common/views/widgets/posts-monitor.vue index 9b2cc5a6cd..1af306b881 100644 --- a/src/client/app/common/views/widgets/posts-monitor.vue +++ b/src/client/app/common/views/widgets/posts-monitor.vue @@ -164,7 +164,7 @@ export default define({ this.draw(); }, onStatsLog(statsLog) { - statsLog.forEach(stats => this.onStats(stats)); + for (const stats of statsLog) this.onStats(stats); } } }); diff --git a/src/client/app/common/views/widgets/server.cpu-memory.vue b/src/client/app/common/views/widgets/server.cpu-memory.vue index 4a0341ddcd..92e5479b1b 100644 --- a/src/client/app/common/views/widgets/server.cpu-memory.vue +++ b/src/client/app/common/views/widgets/server.cpu-memory.vue @@ -121,7 +121,7 @@ export default Vue.extend({ this.memP = (stats.mem.used / stats.mem.total * 100).toFixed(0); }, onStatsLog(statsLog) { - statsLog.reverse().forEach(stats => this.onStats(stats)); + for (const stats of statsLog.reverse()) this.onStats(stats); } } }); diff --git a/src/client/app/desktop/views/components/activity.calendar.vue b/src/client/app/desktop/views/components/activity.calendar.vue index 4306aa9282..9e3e6f0818 100644 --- a/src/client/app/desktop/views/components/activity.calendar.vue +++ b/src/client/app/desktop/views/components/activity.calendar.vue @@ -29,7 +29,9 @@ import Vue from 'vue'; export default Vue.extend({ props: ['data'], created() { - this.data.forEach(d => d.total = d.notes + d.replies + d.renotes); + for (const d of this.data) { + d.total = d.notes + d.replies + d.renotes; + } const peak = Math.max.apply(null, this.data.map(d => d.total)); const now = new Date(); diff --git a/src/client/app/desktop/views/components/activity.chart.vue b/src/client/app/desktop/views/components/activity.chart.vue index a6122ce8e8..7a5004e998 100644 --- a/src/client/app/desktop/views/components/activity.chart.vue +++ b/src/client/app/desktop/views/components/activity.chart.vue @@ -57,7 +57,10 @@ export default Vue.extend({ }; }, created() { - this.data.forEach(d => d.total = d.notes + d.replies + d.renotes); + for (const d of this.data) { + d.total = d.notes + d.replies + d.renotes; + } + this.render(); }, methods: { diff --git a/src/client/app/desktop/views/components/context-menu.vue b/src/client/app/desktop/views/components/context-menu.vue index b0a34866cd..c92ce3a470 100644 --- a/src/client/app/desktop/views/components/context-menu.vue +++ b/src/client/app/desktop/views/components/context-menu.vue @@ -34,9 +34,9 @@ export default Vue.extend({ this.$el.style.left = x + 'px'; this.$el.style.top = y + 'px'; - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.addEventListener('mousedown', this.onMousedown); - }); + } this.$el.style.display = 'block'; @@ -59,9 +59,9 @@ export default Vue.extend({ this.close(); }, close() { - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.removeEventListener('mousedown', this.onMousedown); - }); + } this.$emit('closed'); this.destroyDom(); diff --git a/src/client/app/desktop/views/components/drive.folder.vue b/src/client/app/desktop/views/components/drive.folder.vue index 20d962015d..02f219a98e 100644 --- a/src/client/app/desktop/views/components/drive.folder.vue +++ b/src/client/app/desktop/views/components/drive.folder.vue @@ -120,9 +120,9 @@ export default Vue.extend({ // ファイルだったら if (e.dataTransfer.files.length > 0) { - Array.from(e.dataTransfer.files).forEach(file => { + for (const file of Array.from(e.dataTransfer.files)) { this.browser.upload(file, this.folder); - }); + } return; } diff --git a/src/client/app/desktop/views/components/drive.nav-folder.vue b/src/client/app/desktop/views/components/drive.nav-folder.vue index 813c44ab42..14ab467642 100644 --- a/src/client/app/desktop/views/components/drive.nav-folder.vue +++ b/src/client/app/desktop/views/components/drive.nav-folder.vue @@ -68,9 +68,9 @@ export default Vue.extend({ // ファイルだったら if (e.dataTransfer.files.length > 0) { - Array.from(e.dataTransfer.files).forEach(file => { + for (const file of Array.from(e.dataTransfer.files)) { this.browser.upload(file, this.folder); - }); + } return; } diff --git a/src/client/app/desktop/views/components/drive.vue b/src/client/app/desktop/views/components/drive.vue index 068d8a8449..144c4f88f6 100644 --- a/src/client/app/desktop/views/components/drive.vue +++ b/src/client/app/desktop/views/components/drive.vue @@ -277,9 +277,9 @@ export default Vue.extend({ // ドロップされてきたものがファイルだったら if (e.dataTransfer.files.length > 0) { - Array.from(e.dataTransfer.files).forEach(file => { + for (const file of Array.from(e.dataTransfer.files)) { this.upload(file, this.folder); - }); + } return; } @@ -368,9 +368,9 @@ export default Vue.extend({ }, onChangeFileInput() { - Array.from((this.$refs.fileInput as any).files).forEach(file => { + for (const file of Array.from((this.$refs.fileInput as any).files)) { this.upload(file, this.folder); - }); + } }, upload(file, folder) { @@ -549,8 +549,8 @@ export default Vue.extend({ let flag = false; const complete = () => { if (flag) { - fetchedFolders.forEach(this.appendFolder); - fetchedFiles.forEach(this.appendFile); + for (const x of fetchedFolders) this.appendFolder(x); + for (const x of fetchedFiles) this.appendFile(x); this.fetching = false; } else { flag = true; @@ -575,7 +575,7 @@ export default Vue.extend({ } else { this.moreFiles = false; } - files.forEach(this.appendFile); + for (const x of files) this.appendFile(x); this.fetching = false; }); } diff --git a/src/client/app/desktop/views/components/emoji-picker-dialog.vue b/src/client/app/desktop/views/components/emoji-picker-dialog.vue index 06dbe75846..0b18a85000 100644 --- a/src/client/app/desktop/views/components/emoji-picker-dialog.vue +++ b/src/client/app/desktop/views/components/emoji-picker-dialog.vue @@ -43,9 +43,9 @@ export default Vue.extend({ this.$el.style.left = x + 'px'; this.$el.style.top = y + 'px'; - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.addEventListener('mousedown', this.onMousedown); - }); + } }); }, @@ -62,9 +62,9 @@ export default Vue.extend({ }, close() { - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.removeEventListener('mousedown', this.onMousedown); - }); + } this.$emit('closed'); this.destroyDom(); diff --git a/src/client/app/desktop/views/components/home.vue b/src/client/app/desktop/views/components/home.vue index cc0b48e897..18cb215202 100644 --- a/src/client/app/desktop/views/components/home.vue +++ b/src/client/app/desktop/views/components/home.vue @@ -102,23 +102,23 @@ const defaultDesktopHomeWidgets = { //#region Construct home data const _defaultDesktopHomeWidgets = []; -defaultDesktopHomeWidgets.left.forEach(widget => { +for (const widget of defaultDesktopHomeWidgets.left) { _defaultDesktopHomeWidgets.push({ name: widget, id: uuid(), place: 'left', data: {} }); -}); +} -defaultDesktopHomeWidgets.right.forEach(widget => { +for (const widget of defaultDesktopHomeWidgets.right) { _defaultDesktopHomeWidgets.push({ name: widget, id: uuid(), place: 'right', data: {} }); -}); +} //#endregion export default Vue.extend({ @@ -220,8 +220,8 @@ export default Vue.extend({ const left = this.widgets.left; const right = this.widgets.right; this.$store.commit('settings/setHome', left.concat(right)); - left.forEach(w => w.place = 'left'); - right.forEach(w => w.place = 'right'); + for (const w of left) w.place = 'left'; + for (const w of right) w.place = 'right'; this.$root.api('i/update_home', { home: this.home }); diff --git a/src/client/app/desktop/views/components/notes.vue b/src/client/app/desktop/views/components/notes.vue index 0e710feb69..eb108e4e5e 100644 --- a/src/client/app/desktop/views/components/notes.vue +++ b/src/client/app/desktop/views/components/notes.vue @@ -156,7 +156,9 @@ export default Vue.extend({ }, releaseQueue() { - this.queue.forEach(n => this.prepend(n, true)); + for (const n of this.queue) { + this.prepend(n, true); + } this.queue = []; }, diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index 5b6fc4cd46..ef236e96b6 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -184,7 +184,8 @@ export default Vue.extend({ if (this.reply && this.reply.text != null) { const ast = parse(this.reply.text); - ast.filter(t => t.type == 'mention').forEach(x => { + // TODO: 新しいMFMパーサに対応 + for (const x of ast.filter(t => t.type == 'mention')) { const mention = x.host ? `@${x.username}@${toASCII(x.host)}` : `@${x.username}`; // 自分は除外 @@ -195,7 +196,7 @@ export default Vue.extend({ if (this.text.indexOf(`${mention} `) != -1) return; this.text += `${mention} `; - }); + } } // デフォルト公開範囲 @@ -261,7 +262,7 @@ export default Vue.extend({ this.$chooseDriveFile({ multiple: true }).then(files => { - files.forEach(this.attachMedia); + for (const x of files) this.attachMedia(x); }); }, @@ -276,7 +277,7 @@ export default Vue.extend({ }, onChangeFile() { - Array.from((this.$refs.file as any).files).forEach(this.upload); + for (const x of Array.from((this.$refs.file as any).files)) this.upload(x); }, onPollUpdate() { @@ -304,11 +305,11 @@ export default Vue.extend({ }, onPaste(e) { - Array.from(e.clipboardData.items).forEach((item: any) => { + for (const item of Array.from(e.clipboardData.items)) { if (item.kind == 'file') { this.upload(item.getAsFile()); } - }); + } }, onDragover(e) { @@ -335,7 +336,7 @@ export default Vue.extend({ // ファイルだったら if (e.dataTransfer.files.length > 0) { e.preventDefault(); - Array.from(e.dataTransfer.files).forEach(this.upload); + for (const x of Array.from(e.dataTransfer.files)) this.upload(x); return; } diff --git a/src/client/app/desktop/views/components/timeline.core.vue b/src/client/app/desktop/views/components/timeline.core.vue index f22ab49000..9662157e30 100644 --- a/src/client/app/desktop/views/components/timeline.core.vue +++ b/src/client/app/desktop/views/components/timeline.core.vue @@ -149,7 +149,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/components/ui.header.account.vue b/src/client/app/desktop/views/components/ui.header.account.vue index a16f164556..09f407b0ed 100644 --- a/src/client/app/desktop/views/components/ui.header.account.vue +++ b/src/client/app/desktop/views/components/ui.header.account.vue @@ -120,15 +120,15 @@ export default Vue.extend({ }, open() { this.isOpen = true; - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.addEventListener('mousedown', this.onMousedown); - }); + } }, close() { this.isOpen = false; - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.removeEventListener('mousedown', this.onMousedown); - }); + } }, onMousedown(e) { e.preventDefault(); diff --git a/src/client/app/desktop/views/components/ui.header.notifications.vue b/src/client/app/desktop/views/components/ui.header.notifications.vue index b83a5da04c..ddd1b86610 100644 --- a/src/client/app/desktop/views/components/ui.header.notifications.vue +++ b/src/client/app/desktop/views/components/ui.header.notifications.vue @@ -42,16 +42,16 @@ export default Vue.extend({ open() { this.isOpen = true; - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.addEventListener('mousedown', this.onMousedown); - }); + } }, close() { this.isOpen = false; - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.removeEventListener('mousedown', this.onMousedown); - }); + } }, onMousedown(e) { diff --git a/src/client/app/desktop/views/components/ui.sidebar.vue b/src/client/app/desktop/views/components/ui.sidebar.vue index 9bf68f1efe..8b5f14290c 100644 --- a/src/client/app/desktop/views/components/ui.sidebar.vue +++ b/src/client/app/desktop/views/components/ui.sidebar.vue @@ -171,16 +171,16 @@ export default Vue.extend({ openNotifications() { this.showNotifications = true; - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.addEventListener('mousedown', this.onMousedown); - }); + } }, closeNotifications() { this.showNotifications = false; - Array.from(document.querySelectorAll('body *')).forEach(el => { + for (const el of Array.from(document.querySelectorAll('body *'))) { el.removeEventListener('mousedown', this.onMousedown); - }); + } }, onMousedown(e) { diff --git a/src/client/app/desktop/views/components/user-list-timeline.vue b/src/client/app/desktop/views/components/user-list-timeline.vue index 7bdc016c6c..8afd95a68e 100644 --- a/src/client/app/desktop/views/components/user-list-timeline.vue +++ b/src/client/app/desktop/views/components/user-list-timeline.vue @@ -79,7 +79,7 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) (this.$refs.timeline as any).append(n); this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/components/window.vue b/src/client/app/desktop/views/components/window.vue index 1fac38842a..7eaeed9ada 100644 --- a/src/client/app/desktop/views/components/window.vue +++ b/src/client/app/desktop/views/components/window.vue @@ -234,12 +234,12 @@ export default Vue.extend({ top() { let z = 0; - this.$root.os.windows.getAll().forEach(w => { - if (w == this) return; + const ws = this.$root.os.windows.getAll().filter(w => w != this); + for (const w of ws) { const m = w.$refs.main; const mz = Number(document.defaultView.getComputedStyle(m, null).zIndex); if (mz > z) z = mz; - }); + } if (z > 0) { (this.$refs.main as any).style.zIndex = z + 1; diff --git a/src/client/app/desktop/views/pages/deck/deck.column.vue b/src/client/app/desktop/views/pages/deck/deck.column.vue index 13f7638a09..a84dbdcdc1 100644 --- a/src/client/app/desktop/views/pages/deck/deck.column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.column.vue @@ -224,7 +224,9 @@ export default Vue.extend({ if (this.menu) { items.unshift(null); - this.menu.reverse().forEach(i => items.unshift(i)); + for (const i of this.menu.reverse()) { + items.unshift(i); + } } return items; diff --git a/src/client/app/desktop/views/pages/deck/deck.direct.vue b/src/client/app/desktop/views/pages/deck/deck.direct.vue index 2ceb82ca17..c6c2b99233 100644 --- a/src/client/app/desktop/views/pages/deck/deck.direct.vue +++ b/src/client/app/desktop/views/pages/deck/deck.direct.vue @@ -77,7 +77,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/pages/deck/deck.hashtag-tl.vue b/src/client/app/desktop/views/pages/deck/deck.hashtag-tl.vue index 611bcce4e6..9a70733fda 100644 --- a/src/client/app/desktop/views/pages/deck/deck.hashtag-tl.vue +++ b/src/client/app/desktop/views/pages/deck/deck.hashtag-tl.vue @@ -102,7 +102,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/pages/deck/deck.list-tl.vue b/src/client/app/desktop/views/pages/deck/deck.list-tl.vue index d65745f06f..68fbbb3ff9 100644 --- a/src/client/app/desktop/views/pages/deck/deck.list-tl.vue +++ b/src/client/app/desktop/views/pages/deck/deck.list-tl.vue @@ -104,7 +104,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/pages/deck/deck.mentions.vue b/src/client/app/desktop/views/pages/deck/deck.mentions.vue index 9921b3ca04..5fcabde5d6 100644 --- a/src/client/app/desktop/views/pages/deck/deck.mentions.vue +++ b/src/client/app/desktop/views/pages/deck/deck.mentions.vue @@ -75,7 +75,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/pages/deck/deck.notes.vue b/src/client/app/desktop/views/pages/deck/deck.notes.vue index b484561fd3..fd9042656d 100644 --- a/src/client/app/desktop/views/pages/deck/deck.notes.vue +++ b/src/client/app/desktop/views/pages/deck/deck.notes.vue @@ -164,7 +164,9 @@ export default Vue.extend({ }, releaseQueue() { - this.queue.forEach(n => this.prepend(n, true)); + for (const n of this.queue) { + this.prepend(n, true); + } this.queue = []; }, diff --git a/src/client/app/desktop/views/pages/deck/deck.notifications.vue b/src/client/app/desktop/views/pages/deck/deck.notifications.vue index 430d7d9b2f..60b02bc1fa 100644 --- a/src/client/app/desktop/views/pages/deck/deck.notifications.vue +++ b/src/client/app/desktop/views/pages/deck/deck.notifications.vue @@ -142,7 +142,9 @@ export default Vue.extend({ }, releaseQueue() { - this.queue.forEach(n => this.prepend(n)); + for (const n of this.queue) { + this.prepend(n); + } this.queue = []; }, diff --git a/src/client/app/desktop/views/pages/deck/deck.tl.vue b/src/client/app/desktop/views/pages/deck/deck.tl.vue index 3e87670827..4f5e3af197 100644 --- a/src/client/app/desktop/views/pages/deck/deck.tl.vue +++ b/src/client/app/desktop/views/pages/deck/deck.tl.vue @@ -123,7 +123,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/pages/deck/deck.user-column.vue b/src/client/app/desktop/views/pages/deck/deck.user-column.vue index 6f0b38434f..3e54bbc131 100644 --- a/src/client/app/desktop/views/pages/deck/deck.user-column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.user-column.vue @@ -167,11 +167,11 @@ export default Vue.extend({ limit: 9, untilDate: new Date().getTime() + 1000 * 86400 * 365 }).then(notes => { - notes.forEach(note => { - note.files.forEach(file => { + for (const note of notes) { + for (const file of note.files) { file._note = note; - }); - }); + } + } const files = concat(notes.map((n: any): any[] => n.files)); this.images = files.filter(f => image.includes(f.type)).slice(0, 9); }); @@ -298,7 +298,7 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) (this.$refs.timeline as any).append(n); this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/pages/search.vue b/src/client/app/desktop/views/pages/search.vue index ff644a62dc..fc31673ba8 100644 --- a/src/client/app/desktop/views/pages/search.vue +++ b/src/client/app/desktop/views/pages/search.vue @@ -94,7 +94,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/pages/tag.vue b/src/client/app/desktop/views/pages/tag.vue index 9245f69c99..29e26b6d06 100644 --- a/src/client/app/desktop/views/pages/tag.vue +++ b/src/client/app/desktop/views/pages/tag.vue @@ -83,7 +83,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/pages/user/user.photos.vue b/src/client/app/desktop/views/pages/user/user.photos.vue index 42436ea476..d2723d2cf3 100644 --- a/src/client/app/desktop/views/pages/user/user.photos.vue +++ b/src/client/app/desktop/views/pages/user/user.photos.vue @@ -30,11 +30,11 @@ export default Vue.extend({ limit: 9, untilDate: new Date().getTime() + 1000 * 86400 * 365 }).then(notes => { - notes.forEach(note => { - note.files.forEach(file => { + for (const note of notes) { + for (const file of note.files) { if (this.images.length < 9) this.images.push(file); - }); - }); + } + } this.fetching = false; }); } diff --git a/src/client/app/desktop/views/pages/user/user.timeline.vue b/src/client/app/desktop/views/pages/user/user.timeline.vue index 357a87062b..6d1b23b403 100644 --- a/src/client/app/desktop/views/pages/user/user.timeline.vue +++ b/src/client/app/desktop/views/pages/user/user.timeline.vue @@ -95,7 +95,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/desktop/views/widgets/post-form.vue b/src/client/app/desktop/views/widgets/post-form.vue index 5c8d25ac61..622e5c3345 100644 --- a/src/client/app/desktop/views/widgets/post-form.vue +++ b/src/client/app/desktop/views/widgets/post-form.vue @@ -99,7 +99,7 @@ export default define({ this.$chooseDriveFile({ multiple: true }).then(files => { - files.forEach(this.attachMedia); + for (const x of files) this.attachMedia(x); }); }, @@ -118,15 +118,15 @@ export default define({ }, onPaste(e) { - Array.from(e.clipboardData.items).forEach((item: any) => { + for (const item of Array.from(e.clipboardData.items)) { if (item.kind == 'file') { this.upload(item.getAsFile()); } - }); + } }, onChangeFile() { - Array.from((this.$refs.file as any).files).forEach(this.upload); + for (const x of Array.from((this.$refs.file as any).files)) this.upload(x); }, upload(file) { @@ -146,7 +146,7 @@ export default define({ // ファイルだったら if (e.dataTransfer.files.length > 0) { e.preventDefault(); - Array.from(e.dataTransfer.files).forEach(this.upload); + for (const x of Array.from(e.dataTransfer.files)) this.upload(x); return; } diff --git a/src/client/app/mobile/views/components/drive.vue b/src/client/app/mobile/views/components/drive.vue index e7a5d99832..5fb160f916 100644 --- a/src/client/app/mobile/views/components/drive.vue +++ b/src/client/app/mobile/views/components/drive.vue @@ -297,8 +297,8 @@ export default Vue.extend({ let flag = false; const complete = () => { if (flag) { - fetchedFolders.forEach(this.appendFolder); - fetchedFiles.forEach(this.appendFile); + for (const x of fetchedFolders) this.appendFolder(x); + for (const x of fetchedFiles) this.appendFile(x); this.fetching = false; // 一連の読み込みが完了したイベントを発行 @@ -336,7 +336,7 @@ export default Vue.extend({ } else { this.moreFiles = false; } - files.forEach(this.appendFile); + for (const x of files) this.appendFile(x); this.fetching = false; this.fetchingMoreFiles = false; }); @@ -460,8 +460,9 @@ export default Vue.extend({ }, onChangeLocalFile() { - Array.from((this.$refs.file as any).files) - .forEach(f => (this.$refs.uploader as any).upload(f, this.folder)); + for (const f of Array.from((this.$refs.file as any).files)) { + (this.$refs.uploader as any).upload(f, this.folder); + } } } }); diff --git a/src/client/app/mobile/views/components/notes.vue b/src/client/app/mobile/views/components/notes.vue index 4f0db3e273..088ecd5de0 100644 --- a/src/client/app/mobile/views/components/notes.vue +++ b/src/client/app/mobile/views/components/notes.vue @@ -149,7 +149,9 @@ export default Vue.extend({ }, releaseQueue() { - this.queue.forEach(n => this.prepend(n, true)); + for (const n of this.queue) { + this.prepend(n, true); + } this.queue = []; }, diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index 52bb5f966a..28e008279c 100644 --- a/src/client/app/mobile/views/components/post-form.vue +++ b/src/client/app/mobile/views/components/post-form.vue @@ -174,7 +174,7 @@ export default Vue.extend({ if (this.reply && this.reply.text != null) { const ast = parse(this.reply.text); - ast.filter(t => t.type == 'mention').forEach(x => { + for (const x of ast.filter(t => t.type == 'mention')) { const mention = x.host ? `@${x.username}@${toASCII(x.host)}` : `@${x.username}`; // 自分は除外 @@ -185,7 +185,7 @@ export default Vue.extend({ if (this.text.indexOf(`${mention} `) != -1) return; this.text += `${mention} `; - }); + } } // デフォルト公開範囲 @@ -241,7 +241,7 @@ export default Vue.extend({ this.$chooseDriveFile({ multiple: true }).then(files => { - files.forEach(this.attachMedia); + for (const x of files) this.attachMedia(x); }); }, @@ -256,7 +256,7 @@ export default Vue.extend({ }, onChangeFile() { - Array.from((this.$refs.file as any).files).forEach(this.upload); + for (const x of Array.from((this.$refs.file as any).files)) this.upload(x); }, onPollUpdate() { diff --git a/src/client/app/mobile/views/components/user-list-timeline.vue b/src/client/app/mobile/views/components/user-list-timeline.vue index a9597319df..d90051710b 100644 --- a/src/client/app/mobile/views/components/user-list-timeline.vue +++ b/src/client/app/mobile/views/components/user-list-timeline.vue @@ -94,7 +94,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/mobile/views/components/user-timeline.vue b/src/client/app/mobile/views/components/user-timeline.vue index e8d7adc8b5..0d0bbc4073 100644 --- a/src/client/app/mobile/views/components/user-timeline.vue +++ b/src/client/app/mobile/views/components/user-timeline.vue @@ -76,7 +76,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/mobile/views/pages/home.timeline.vue b/src/client/app/mobile/views/pages/home.timeline.vue index 0699a169e4..91c99bc8fe 100644 --- a/src/client/app/mobile/views/pages/home.timeline.vue +++ b/src/client/app/mobile/views/pages/home.timeline.vue @@ -150,7 +150,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/mobile/views/pages/search.vue b/src/client/app/mobile/views/pages/search.vue index fbabfdf6a0..669e0b740b 100644 --- a/src/client/app/mobile/views/pages/search.vue +++ b/src/client/app/mobile/views/pages/search.vue @@ -77,7 +77,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/mobile/views/pages/tag.vue b/src/client/app/mobile/views/pages/tag.vue index aaf878ce45..e0c9f64941 100644 --- a/src/client/app/mobile/views/pages/tag.vue +++ b/src/client/app/mobile/views/pages/tag.vue @@ -72,7 +72,9 @@ export default Vue.extend({ } else { this.existMore = false; } - notes.forEach(n => (this.$refs.timeline as any).append(n)); + for (const n of notes) { + (this.$refs.timeline as any).append(n); + } this.moreFetching = false; }); diff --git a/src/client/app/mobile/views/pages/user/home.photos.vue b/src/client/app/mobile/views/pages/user/home.photos.vue index 320b102b0c..4fb5b90ff2 100644 --- a/src/client/app/mobile/views/pages/user/home.photos.vue +++ b/src/client/app/mobile/views/pages/user/home.photos.vue @@ -32,14 +32,16 @@ export default Vue.extend({ limit: 6, untilDate: new Date().getTime() + 1000 * 86400 * 365 }).then(notes => { - notes.forEach(note => { - note.media.forEach(media => { - if (this.images.length < 9) this.images.push({ - note, - media - }); - }); - }); + for (const note of notes) { + for (const media of note.media) { + if (this.images.length < 9) { + this.images.push({ + note, + media + }); + } + } + } this.fetching = false; }); } diff --git a/src/client/app/store.ts b/src/client/app/store.ts index 633170e376..f2c301bcbc 100644 --- a/src/client/app/store.ts +++ b/src/client/app/store.ts @@ -136,9 +136,9 @@ export default (os: MiOS) => new Vuex.Store({ }, mergeMe(ctx, me) { - Object.entries(me).forEach(([key, value]) => { + for (const [key, value] of Object.entries(me)) { ctx.commit('updateIKeyValue', { key, value }); - }); + } if (me.clientSettings) { ctx.dispatch('settings/merge', me.clientSettings); @@ -215,11 +215,11 @@ export default (os: MiOS) => new Vuex.Store({ //#region Deck if (state.deck && state.deck.columns) { - state.deck.columns.filter(c => c.type == 'widgets').forEach(c => { - c.widgets.forEach(w => { - if (w.id == x.id) w.data = x.data; - }); - }); + for (const c of state.deck.columns.filter(c => c.type == 'widgets')) { + for (const w of c.widgets.filter(w => w.id == x.id)) { + w.data = x.data; + } + } } //#endregion }, @@ -345,9 +345,9 @@ export default (os: MiOS) => new Vuex.Store({ actions: { merge(ctx, settings) { if (settings == null) return; - Object.entries(settings).forEach(([key, value]) => { + for (const [key, value] of Object.entries(settings)) { ctx.commit('set', { key, value }); - }); + } }, set(ctx, x) { diff --git a/src/client/app/sw.js b/src/client/app/sw.js index d381bfb7a5..ccf6dc818e 100644 --- a/src/client/app/sw.js +++ b/src/client/app/sw.js @@ -62,6 +62,8 @@ self.addEventListener('push', ev => { self.addEventListener('message', ev => { if (ev.data == 'clear') { - caches.keys().then(keys => keys.forEach(key => caches.delete(key))); + caches.keys().then(keys => { + for (const key of keys) caches.delete(key); + }); } }); diff --git a/src/client/app/theme.ts b/src/client/app/theme.ts index 9c5be74fa1..de6546c5b0 100644 --- a/src/client/app/theme.ts +++ b/src/client/app/theme.ts @@ -36,9 +36,9 @@ export function applyTheme(theme: Theme, persisted = true) { const props = compile(_theme); - Object.entries(props).forEach(([k, v]) => { + for (const [k, v] of Object.entries(props)) { document.documentElement.style.setProperty(`--${k}`, v.toString()); - }); + } if (persisted) { localStorage.setItem('theme', JSON.stringify(props)); @@ -74,10 +74,9 @@ function compile(theme: Theme): { [key: string]: string } { const props = {}; - Object.entries(theme.props).forEach(([k, v]) => { - const c = getColor(v); - props[k] = genValue(c); - }); + for (const [k, v] of Object.entries(theme.props)) { + props[k] = genValue(getColor(v)); + } const primary = getColor(props['primary']); diff --git a/src/mfm/html-to-mfm.ts b/src/mfm/html-to-mfm.ts index 9a9fbbb86c..dcd0e7fa7e 100644 --- a/src/mfm/html-to-mfm.ts +++ b/src/mfm/html-to-mfm.ts @@ -8,7 +8,9 @@ export default function(html: string): string { let text = ''; - dom.childNodes.forEach((n: any) => analyze(n)); + for (const n of dom.childNodes) { + analyze(n); + } return text.trim(); @@ -61,13 +63,17 @@ export default function(html: string): string { case 'p': text += '\n\n'; if (node.childNodes) { - node.childNodes.forEach((n: any) => analyze(n)); + for (const n of node.childNodes) { + analyze(n); + } } break; default: if (node.childNodes) { - node.childNodes.forEach((n: any) => analyze(n)); + for (const n of node.childNodes) { + analyze(n); + } } break; } diff --git a/src/mfm/parse.ts b/src/mfm/parse.ts index 0dc749a5f8..58e126be3e 100644 --- a/src/mfm/parse.ts +++ b/src/mfm/parse.ts @@ -17,21 +17,20 @@ export default (source: string, plainText = false): Node[] => { es[0].name === 'text' ? [combineText(es)] : es )); - const concatTextRecursive = (es: Node[]): void => - es.filter(x => x.children).forEach(x => { + const concatTextRecursive = (es: Node[]): void => { + for (const x of es.filter(x => x.children)) { x.children = concatText(x.children); concatTextRecursive(x.children); - }); + } + }; nodes = concatText(nodes); concatTextRecursive(nodes); const removeEmptyTextNodes = (nodes: Node[]) => { - nodes.forEach(n => { - if (n.children) { - n.children = removeEmptyTextNodes(n.children); - } - }); + for (const n of nodes.filter(n => n.children)) { + n.children = removeEmptyTextNodes(n.children); + } return nodes.filter(n => !(n.name == 'text' && n.props.text == '')); }; diff --git a/src/prelude/array.ts b/src/prelude/array.ts index 5f694b1d31..5a8f36450a 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -34,6 +34,10 @@ export function sum(xs: number[]): number { return xs.reduce((a, b) => a + b, 0); } +export function maximum(xs: number[]): number { + return Math.max(...xs); +} + export function groupBy(f: (x: T, y: T) => boolean, xs: T[]): T[][] { const groups = [] as T[][]; for (const x of xs) { diff --git a/src/push-sw.ts b/src/push-sw.ts index d30965f800..2c09d0547e 100644 --- a/src/push-sw.ts +++ b/src/push-sw.ts @@ -23,7 +23,7 @@ export default async function(userId: mongo.ObjectID | string, type: string, bod userId: userId }); - subscriptions.forEach(subscription => { + for (const subscription of subscriptions) { const pushSubscription = { endpoint: subscription.endpoint, keys: { @@ -48,5 +48,5 @@ export default async function(userId: mongo.ObjectID | string, type: string, bod }); } }); - }); + } } diff --git a/src/server/api/endpoints/aggregation/hashtags.ts b/src/server/api/endpoints/aggregation/hashtags.ts index 45d709f772..7577711b5f 100644 --- a/src/server/api/endpoints/aggregation/hashtags.ts +++ b/src/server/api/endpoints/aggregation/hashtags.ts @@ -47,10 +47,7 @@ export default define(meta, (ps) => new Promise(async (res, rej) => { }> = []; // カウント - data.map(x => x._id).forEach(x => { - // ブラックリストに登録されているタグなら弾く - if (hidedTags.includes(x.tag)) return; - + for (const x of data.map(x => x._id).filter(x => !hidedTags.includes(x.tag))) { const i = tags.findIndex(tag => tag.name == x.tag); if (i != -1) { tags[i].count++; @@ -60,7 +57,7 @@ export default define(meta, (ps) => new Promise(async (res, rej) => { count: 1 }); } - }); + } // タグを人気順に並べ替え tags.sort((a, b) => b.count - a.count); diff --git a/src/server/api/endpoints/drive/files/update.ts b/src/server/api/endpoints/drive/files/update.ts index a5835c6d65..7f9eb7bad3 100644 --- a/src/server/api/endpoints/drive/files/update.ts +++ b/src/server/api/endpoints/drive/files/update.ts @@ -100,14 +100,14 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { Note.find({ '_files._id': file._id }).then(notes => { - notes.forEach(note => { + for (const note of notes) { note._files[note._files.findIndex(f => f._id.equals(file._id))] = file; Note.update({ _id: note._id }, { $set: { _files: note._files } }); - }); + } }); // Serialize diff --git a/src/server/api/endpoints/games/reversi/games/show.ts b/src/server/api/endpoints/games/reversi/games/show.ts index c747202354..0882456102 100644 --- a/src/server/api/endpoints/games/reversi/games/show.ts +++ b/src/server/api/endpoints/games/reversi/games/show.ts @@ -25,9 +25,8 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { loopedBoard: game.settings.loopedBoard }); - game.logs.forEach(log => { + for (const log of game.logs) o.put(log.color, log.pos); - }); const packed = await pack(game, user); diff --git a/src/server/api/endpoints/hashtags/trend.ts b/src/server/api/endpoints/hashtags/trend.ts index ed4c8e337f..a26dbf0941 100644 --- a/src/server/api/endpoints/hashtags/trend.ts +++ b/src/server/api/endpoints/hashtags/trend.ts @@ -58,10 +58,7 @@ export default define(meta, () => new Promise(async (res, rej) => { }> = []; // カウント - data.map(x => x._id).forEach(x => { - // ブラックリストに登録されているタグなら弾く - if (hidedTags.includes(x.tag)) return; - + for (const x of data.map(x => x._id).filter(x => !hidedTags.includes(x.tag))) { const i = tags.findIndex(tag => tag.name == x.tag); if (i != -1) { tags[i].count++; @@ -71,7 +68,7 @@ export default define(meta, () => new Promise(async (res, rej) => { count: 1 }); } - }); + } // 最低要求投稿者数を下回るならカットする const limitedTags = tags.filter(tag => tag.count >= requiredUsers); diff --git a/src/server/api/endpoints/i/update_widget.ts b/src/server/api/endpoints/i/update_widget.ts index 90fe8fbe23..da96ec6fc1 100644 --- a/src/server/api/endpoints/i/update_widget.ts +++ b/src/server/api/endpoints/i/update_widget.ts @@ -59,11 +59,11 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { //#region Deck if (widget == null && user.clientSettings.deck && user.clientSettings.deck.columns) { const deck = user.clientSettings.deck; - deck.columns.filter((c: any) => c.type == 'widgets').forEach((c: any) => { - c.widgets.forEach((w: any) => { - if (w.id == ps.id) widget = w; - }); - }); + for (const c of deck.columns.filter((c: any) => c.type == 'widgets')) { + for (const w of c.widgets.filter((w: any) => w.id == ps.id)) { + widget = w; + } + } if (widget) { widget.data = ps.data; diff --git a/src/server/api/endpoints/notes/mentions.ts b/src/server/api/endpoints/notes/mentions.ts index 718f5e4403..a353165cd0 100644 --- a/src/server/api/endpoints/notes/mentions.ts +++ b/src/server/api/endpoints/notes/mentions.ts @@ -91,5 +91,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { res(await packMany(mentions, user)); - mentions.forEach(note => read(user._id, note._id)); + for (const note of mentions) { + read(user._id, note._id); + } })); diff --git a/src/server/api/endpoints/notes/polls/vote.ts b/src/server/api/endpoints/notes/polls/vote.ts index dc012152c6..8de0eb420e 100644 --- a/src/server/api/endpoints/notes/polls/vote.ts +++ b/src/server/api/endpoints/notes/polls/vote.ts @@ -102,12 +102,12 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { } }) .then(watchers => { - watchers.forEach(watcher => { + for (const watcher of watchers) { notify(watcher.userId, user._id, 'poll_vote', { noteId: note._id, choice: ps.choice }); - }); + } }); // この投稿をWatchする diff --git a/src/server/api/endpoints/users/get_frequently_replied_users.ts b/src/server/api/endpoints/users/get_frequently_replied_users.ts index cf123b82ba..353ccef1e9 100644 --- a/src/server/api/endpoints/users/get_frequently_replied_users.ts +++ b/src/server/api/endpoints/users/get_frequently_replied_users.ts @@ -2,6 +2,7 @@ import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id'; import Note from '../../../../models/note'; import User, { pack } from '../../../../models/user'; import define from '../../define'; +import { maximum } from '../../../../prelude/array'; export const meta = { requireCredential: false, @@ -77,20 +78,16 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { const repliedUsers: any = {}; // Extract replies from recent notes - replyTargetNotes.forEach(note => { - const userId = note.userId.toString(); + for (const userId of replyTargetNotes.map(x => x.userId.toString())) { if (repliedUsers[userId]) { repliedUsers[userId]++; } else { repliedUsers[userId] = 1; } - }); + } // Calc peak - let peak = 0; - Object.keys(repliedUsers).forEach(user => { - if (repliedUsers[user] > peak) peak = repliedUsers[user]; - }); + const peak = maximum(Object.values(repliedUsers)); // Sort replies by frequency const repliedUsersSorted = Object.keys(repliedUsers).sort((a, b) => repliedUsers[b] - repliedUsers[a]); diff --git a/src/server/api/index.ts b/src/server/api/index.ts index ebb3d5a27f..04fc8759f9 100644 --- a/src/server/api/index.ts +++ b/src/server/api/index.ts @@ -41,10 +41,13 @@ const router = new Router(); /** * Register endpoint handlers */ -endpoints.forEach(endpoint => endpoint.meta.requireFile - ? router.post(`/${endpoint.name}`, upload.single('file'), handler.bind(null, endpoint)) - : router.post(`/${endpoint.name}`, handler.bind(null, endpoint)) -); +for (const endpoint of endpoints) { + if (endpoint.meta.requireFile) { + router.post(`/${endpoint.name}`, upload.single('file'), handler.bind(null, endpoint)); + } else { + router.post(`/${endpoint.name}`, handler.bind(null, endpoint)); + } +} router.post('/signup', require('./private/signup').default); router.post('/signin', require('./private/signin').default); diff --git a/src/server/api/stream/channels/games/reversi-game.ts b/src/server/api/stream/channels/games/reversi-game.ts index f287ad0107..1cb077c8c4 100644 --- a/src/server/api/stream/channels/games/reversi-game.ts +++ b/src/server/api/stream/channels/games/reversi-game.ts @@ -242,9 +242,9 @@ export default class extends Channel { loopedBoard: game.settings.loopedBoard }); - game.logs.forEach(log => { + for (const log of game.logs) { o.put(log.color, log.pos); - }); + } const myColor = (game.user1Id.equals(this.user._id) && game.black == 1) || (game.user2Id.equals(this.user._id) && game.black == 2) diff --git a/src/server/api/stream/index.ts b/src/server/api/stream/index.ts index 3119e20af8..22f7646cb9 100644 --- a/src/server/api/stream/index.ts +++ b/src/server/api/stream/index.ts @@ -213,8 +213,8 @@ export default class Connection { */ @autobind public dispose() { - this.channels.forEach(c => { - if (c.dispose) c.dispose(); - }); + for (const c of this.channels.filter(c => c.dispose)) { + c.dispose(); + } } } diff --git a/src/server/index.ts b/src/server/index.ts index 88a39cd24a..86dfd4b753 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -91,9 +91,9 @@ app.use(mount(require('./web'))); function createServer() { if (config.https) { const certs: any = {}; - Object.keys(config.https).forEach(k => { + for (const k of Object.keys(config.https)) { certs[k] = fs.readFileSync(config.https[k]); - }); + } certs['allowHTTP1'] = true; return http2.createSecureServer(certs, app.callback()); } else { diff --git a/src/server/web/docs.ts b/src/server/web/docs.ts index 9cc54cdf0b..f9991fc65c 100644 --- a/src/server/web/docs.ts +++ b/src/server/web/docs.ts @@ -36,7 +36,7 @@ async function genVars(lang: string): Promise<{ [key: string]: any }> { const docs = glob.sync(`src/docs/**/*.${lang}.md`, { cwd }); vars['docs'] = {}; - docs.forEach(x => { + for (const x of docs) { const [, name] = x.match(/docs\/(.+?)\.(.+?)\.md$/); if (vars['docs'][name] == null) { vars['docs'][name] = { @@ -45,7 +45,7 @@ async function genVars(lang: string): Promise<{ [key: string]: any }> { }; } vars['docs'][name]['title'][lang] = fs.readFileSync(cwd + x, 'utf-8').match(/^# (.+?)\r?\n/)[1]; - }); + } vars['kebab'] = (string: string) => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); @@ -121,7 +121,7 @@ const sortParams = (params: Array<{ name: string }>) => { const extractParamDefRef = (params: Context[]) => { let defs: any[] = []; - params.forEach(param => { + for (const param of params) { if (param.data && param.data.ref) { const props = (param as ObjectContext).props; defs.push({ @@ -133,7 +133,7 @@ const extractParamDefRef = (params: Context[]) => { defs = defs.concat(childDefs); } - }); + } return sortParams(defs); }; @@ -141,7 +141,7 @@ const extractParamDefRef = (params: Context[]) => { const extractPropDefRef = (props: any[]) => { let defs: any[] = []; - Object.entries(props).forEach(([k, v]) => { + for (const [k, v] of Object.entries(props)) { if (v.props) { defs.push({ name: k, @@ -152,7 +152,7 @@ const extractPropDefRef = (props: any[]) => { defs = defs.concat(childDefs); } - }); + } return sortParams(defs); }; diff --git a/src/services/following/requests/accept-all.ts b/src/services/following/requests/accept-all.ts index 45da004988..cf1a9e923d 100644 --- a/src/services/following/requests/accept-all.ts +++ b/src/services/following/requests/accept-all.ts @@ -11,10 +11,10 @@ export default async function(user: IUser) { followeeId: user._id }); - requests.forEach(async request => { + for (const request of requests) { const follower = await User.findOne({ _id: request.followerId }); accept(user, follower); - }); + } User.update({ _id: user._id }, { $set: { diff --git a/src/services/i/pin.ts b/src/services/i/pin.ts index bcd5465c04..6a42982e6c 100644 --- a/src/services/i/pin.ts +++ b/src/services/i/pin.ts @@ -101,9 +101,9 @@ export async function deliverPinnedChange(userId: mongo.ObjectID, noteId: mongo. const item = `${config.url}/notes/${noteId}`; const content = packAp(isAddition ? renderAdd(user, target, item) : renderRemove(user, target, item)); - queue.forEach(inbox => { + for (const inbox of queue) { deliver(user, content, inbox); - }); + } } /** diff --git a/src/services/i/update.ts b/src/services/i/update.ts index 3d17c07963..242fbd3aa2 100644 --- a/src/services/i/update.ts +++ b/src/services/i/update.ts @@ -30,9 +30,9 @@ export async function publishToFollowers(userId: mongo.ObjectID) { if (queue.length > 0) { const content = packAp(renderUpdate(await renderPerson(user), user)); - queue.forEach(inbox => { + for (const inbox of queue) { deliver(user, content, inbox); - }); + } } } } diff --git a/src/services/note/create.ts b/src/services/note/create.ts index fd76af6b9f..eef36505ab 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -65,8 +65,8 @@ class NotificationManager { } } - public deliver() { - this.queue.forEach(async x => { + public async deliver() { + for (const x of this.queue) { // ミュート情報を取得 const mentioneeMutes = await Mute.find({ muterId: x.target @@ -80,7 +80,7 @@ class NotificationManager { noteId: this.note._id }); } - }); + } } } @@ -175,11 +175,11 @@ export default async (user: IUser, data: Option, silent = false) => new Promise< } if (data.visibility == 'specified') { - data.visibleUsers.forEach(u => { + for (const u of data.visibleUsers) { if (!mentionedUsers.some(x => x._id.equals(u._id))) { mentionedUsers.push(u); } - }); + } } const note = await insertNote(user, data, tags, emojis, mentionedUsers); @@ -213,13 +213,13 @@ export default async (user: IUser, data: Option, silent = false) => new Promise< // ファイルが添付されていた場合ドライブのファイルの「このファイルが添付された投稿一覧」プロパティにこの投稿を追加 if (data.files) { - data.files.forEach(file => { + for (const file of data.files) { DriveFile.update({ _id: file._id }, { $push: { 'metadata.attachedNoteIds': note._id } }); - }); + } } // Increment notes count @@ -230,13 +230,13 @@ export default async (user: IUser, data: Option, silent = false) => new Promise< // 未読通知を作成 if (data.visibility == 'specified') { - data.visibleUsers.forEach(u => { + for (const u of data.visibleUsers) { insertNoteUnread(u, note, true); - }); + } } else { - mentionedUsers.forEach(u => { + for (const u of mentionedUsers) { insertNoteUnread(u, note, false); - }); + } } if (data.reply) { @@ -469,12 +469,12 @@ function extractHashtags(tokens: ReturnType): string[] { const hashtags: string[] = []; const extract = (tokens: Node[]) => { - tokens.filter(x => x.name === 'hashtag').forEach(x => { + for (const x of tokens.filter(x => x.name === 'hashtag')) { hashtags.push(x.props.hashtag); - }); - tokens.filter(x => x.children).forEach(x => { + } + for (const x of tokens.filter(x => x.children)) { extract(x.children); - }); + } }; // Extract hashtags @@ -487,14 +487,14 @@ export function extractEmojis(tokens: ReturnType): string[] { const emojis: string[] = []; const extract = (tokens: Node[]) => { - tokens.filter(x => x.name === 'emoji').forEach(x => { + for (const x of tokens.filter(x => x.name === 'emoji')) { if (x.props.name && x.props.name.length <= 100) { emojis.push(x.props.name); } - }); - tokens.filter(x => x.children).forEach(x => { + } + for (const x of tokens.filter(x => x.children)) { extract(x.children); - }); + } }; // Extract emojis @@ -526,9 +526,9 @@ async function notifyToWatchersOfRenotee(renote: INote, user: IUser, nm: Notific } }); - watchers.forEach(watcher => { + for (const watcher of watchers) { nm.push(watcher.userId, type); - }); + } } async function notifyToWatchersOfReplyee(reply: INote, user: IUser, nm: NotificationManager) { @@ -541,9 +541,9 @@ async function notifyToWatchersOfReplyee(reply: INote, user: IUser, nm: Notifica } }); - watchers.forEach(watcher => { + for (const watcher of watchers) { nm.push(watcher.userId, 'reply'); - }); + } } async function publishToUserLists(note: INote, noteObj: any) { @@ -551,9 +551,9 @@ async function publishToUserLists(note: INote, noteObj: any) { userIds: note.userId }); - lists.forEach(list => { + for (const list of lists) { publishUserListStream(list._id, 'note', noteObj); - }); + } } async function publishToFollowers(note: INote, user: IUser, noteActivity: any) { @@ -594,19 +594,19 @@ async function publishToFollowers(note: INote, user: IUser, noteActivity: any) { } } - queue.forEach(inbox => { + for (const inbox of queue) { deliver(user as any, noteActivity, inbox); - }); + } } function deliverNoteToMentionedRemoteUsers(mentionedUsers: IUser[], user: ILocalUser, noteActivity: any) { - mentionedUsers.filter(u => isRemoteUser(u)).forEach(async (u) => { + for (const u of mentionedUsers.filter(u => isRemoteUser(u))) { deliver(user, noteActivity, (u as IRemoteUser).inbox); - }); + } } -function createMentionedEvents(mentionedUsers: IUser[], note: INote, nm: NotificationManager) { - mentionedUsers.filter(u => isLocalUser(u)).forEach(async (u) => { +async function createMentionedEvents(mentionedUsers: IUser[], note: INote, nm: NotificationManager) { + for (const u of mentionedUsers.filter(u => isLocalUser(u))) { const detailPackedNote = await pack(note, u, { detail: true }); @@ -615,7 +615,7 @@ function createMentionedEvents(mentionedUsers: IUser[], note: INote, nm: Notific // Create notification nm.push(u._id, 'mention'); - }); + } } function saveQuote(renote: INote, note: INote) { @@ -668,12 +668,12 @@ async function extractMentionedUsers(user: IUser, tokens: ReturnType { - tokens.filter(x => x.name === 'mention').forEach(x => { + for (const x of tokens.filter(x => x.name === 'mention')) { mentions.push(x.props); - }); - tokens.filter(x => x.children).forEach(x => { + } + for (const x of tokens.filter(x => x.children)) { extract(x.children); - }); + } }; // Extract hashtags diff --git a/src/services/note/delete.ts b/src/services/note/delete.ts index 599525ac8c..9709eeaf5e 100644 --- a/src/services/note/delete.ts +++ b/src/services/note/delete.ts @@ -44,20 +44,20 @@ export default async function(user: IUser, note: INote) { NoteUnread.find({ noteId: note._id }).then(unreads => { - unreads.forEach(unread => { + for (const unread of unreads) { read(unread.userId, unread.noteId); - }); + } }); // ファイルが添付されていた場合ドライブのファイルの「このファイルが添付された投稿一覧」プロパティからこの投稿を削除 if (note.fileIds) { - note.fileIds.forEach(fileId => { + for (const fileId of note.fileIds) { DriveFile.update({ _id: fileId }, { $pull: { 'metadata.attachedNoteIds': note._id } }); - }); + } } //#region ローカルの投稿なら削除アクティビティを配送 @@ -69,9 +69,9 @@ export default async function(user: IUser, note: INote) { '_follower.host': { $ne: null } }); - followings.forEach(following => { + for (const following of followings) { deliver(user, content, following._follower.inbox); - }); + } } //#endregion diff --git a/src/services/note/reaction/create.ts b/src/services/note/reaction/create.ts index 4a09cf535f..4f56f399a8 100644 --- a/src/services/note/reaction/create.ts +++ b/src/services/note/reaction/create.ts @@ -70,12 +70,12 @@ export default async (user: IUser, note: INote, reaction: string) => new Promise } }) .then(watchers => { - watchers.forEach(watcher => { + for (const watcher of watchers) { notify(watcher.userId, user._id, 'reaction', { noteId: note._id, reaction: reaction }); - }); + } }); // ユーザーがローカルユーザーかつ自動ウォッチ設定がオンならばこの投稿をWatchする diff --git a/tslint.json b/tslint.json index 1adc0a2aed..6c9af508bb 100644 --- a/tslint.json +++ b/tslint.json @@ -31,6 +31,10 @@ "member-ordering": [false], "ban-types": [ "Object" + ], + "ban": [ + true, + {"name": ["*", "forEach"], "message": "Use for-of loop instead."} ] }, "rulesDirectory": []