Use for-of instead of forEach (#3583)

Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
Aya Morisawa
2018-12-11 20:36:55 +09:00
committed by GitHub
parent 30c53e9ee0
commit 125849673a
84 changed files with 345 additions and 283 deletions

View File

@@ -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)
}
}
}
});

View File

@@ -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);
}
}
}
});

View File

@@ -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;
});
},

View File

@@ -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;
});
},

View File

@@ -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);

View File

@@ -1,6 +1,6 @@
import Vue from 'vue';
export default function<T extends object>(data: {
export default function <T extends object>(data: {
name: string;
props?: () => T;
}) {
@@ -53,11 +53,10 @@ export default function<T extends object>(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]);
}
}
},

View File

@@ -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;
});

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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
});
}
});
}
}
}
});

View File

@@ -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 == '') {

View File

@@ -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;
});
}

View File

@@ -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);
}
}
});

View File

@@ -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);
}
}
});

View File

@@ -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();

View File

@@ -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: {

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
});
}

View File

@@ -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();

View File

@@ -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
});

View File

@@ -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 = [];
},

View File

@@ -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;
}

View File

@@ -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;
});

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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;
});

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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 = [];
},

View File

@@ -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 = [];
},

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});
}

View File

@@ -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;
});

View File

@@ -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;
}

View File

@@ -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);
}
}
}
});

View File

@@ -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 = [];
},

View File

@@ -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() {

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});

View File

@@ -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;
});
}

View File

@@ -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) {

View File

@@ -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);
});
}
});

View File

@@ -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']);