diff options
| author | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-09-07 00:02:55 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2018-09-07 00:02:55 +0900 |
| commit | 00d79487cd89f3cae675ecc0392c47ba547b69a5 (patch) | |
| tree | a55b9cf9240fce4ca853d78e004dac75f8c06002 /src/client | |
| parent | Add concat function (#2640) (diff) | |
| download | misskey-00d79487cd89f3cae675ecc0392c47ba547b69a5.tar.gz misskey-00d79487cd89f3cae675ecc0392c47ba547b69a5.tar.bz2 misskey-00d79487cd89f3cae675ecc0392c47ba547b69a5.zip | |
Add erase function (#2641)
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/app/common/scripts/streaming/stream-manager.ts | 3 | ||||
| -rw-r--r-- | src/client/app/common/views/components/poll-editor.vue | 3 | ||||
| -rw-r--r-- | src/client/app/desktop/views/components/post-form.vue | 3 | ||||
| -rw-r--r-- | src/client/app/mios.ts | 3 | ||||
| -rw-r--r-- | src/client/app/mobile/views/components/post-form.vue | 3 | ||||
| -rw-r--r-- | src/client/app/store.ts | 7 | ||||
| -rw-r--r-- | src/client/app/sw.js | 4 |
7 files changed, 16 insertions, 10 deletions
diff --git a/src/client/app/common/scripts/streaming/stream-manager.ts b/src/client/app/common/scripts/streaming/stream-manager.ts index 568b8b0372..8dd06f67d3 100644 --- a/src/client/app/common/scripts/streaming/stream-manager.ts +++ b/src/client/app/common/scripts/streaming/stream-manager.ts @@ -1,6 +1,7 @@ import { EventEmitter } from 'eventemitter3'; import * as uuid from 'uuid'; import Connection from './stream'; +import { erase } from '../../../../../prelude/array'; /** * ストリーム接続を管理するクラス @@ -89,7 +90,7 @@ export default abstract class StreamManager<T extends Connection> extends EventE * @param userId use で発行したユーザーID */ public dispose(userId) { - this.users = this.users.filter(id => id != userId); + this.users = erase(userId, this.users); this._connection.user = `Managed (${ this.users.length })`; diff --git a/src/client/app/common/views/components/poll-editor.vue b/src/client/app/common/views/components/poll-editor.vue index 115c934c8b..30d9799fec 100644 --- a/src/client/app/common/views/components/poll-editor.vue +++ b/src/client/app/common/views/components/poll-editor.vue @@ -20,6 +20,7 @@ <script lang="ts"> import Vue from 'vue'; +import { erase } from '../../../../../prelude/array'; export default Vue.extend({ data() { return { @@ -53,7 +54,7 @@ export default Vue.extend({ get() { return { - choices: this.choices.filter(choice => choice != '') + choices: erase('', this.choices) } }, diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index f6f52c8f1f..65dc9eb9c2 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -62,6 +62,7 @@ import getFace from '../../../common/scripts/get-face'; import MkVisibilityChooser from '../../../common/views/components/visibility-chooser.vue'; import parse from '../../../../../mfm/parse'; import { host } from '../../../config'; +import { erase } from '../../../../../prelude/array'; export default Vue.extend({ components: { @@ -346,7 +347,7 @@ export default Vue.extend({ }, removeVisibleUser(user) { - this.visibleUsers = this.visibleUsers.filter(u => u != user); + this.visibleUsers = erase(user, this.visibleUsers); }, post() { diff --git a/src/client/app/mios.ts b/src/client/app/mios.ts index c2ec7f1750..0f72cd2f34 100644 --- a/src/client/app/mios.ts +++ b/src/client/app/mios.ts @@ -17,6 +17,7 @@ import Err from './common/views/components/connect-failed.vue'; import { LocalTimelineStreamManager } from './common/scripts/streaming/local-timeline'; import { HybridTimelineStreamManager } from './common/scripts/streaming/hybrid-timeline'; import { GlobalTimelineStreamManager } from './common/scripts/streaming/global-timeline'; +import { erase } from '../../prelude/array'; //#region api requests let spinner = null; @@ -537,7 +538,7 @@ export default class MiOS extends EventEmitter { } public unregisterStreamConnection(connection: Connection) { - this.connections = this.connections.filter(c => c != connection); + this.connections = erase(connection, this.connections); } } diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index 644e27cce8..8107c1f3a7 100644 --- a/src/client/app/mobile/views/components/post-form.vue +++ b/src/client/app/mobile/views/components/post-form.vue @@ -59,6 +59,7 @@ import MkVisibilityChooser from '../../../common/views/components/visibility-cho import getFace from '../../../common/scripts/get-face'; import parse from '../../../../../mfm/parse'; import { host } from '../../../config'; +import { erase } from '../../../../../prelude/array'; export default Vue.extend({ components: { @@ -262,7 +263,7 @@ export default Vue.extend({ }, removeVisibleUser(user) { - this.visibleUsers = this.visibleUsers.filter(u => u != user); + this.visibleUsers = erase(user, this.visibleUsers); }, clear() { diff --git a/src/client/app/store.ts b/src/client/app/store.ts index 53f3eefc08..08dd9f9920 100644 --- a/src/client/app/store.ts +++ b/src/client/app/store.ts @@ -4,6 +4,7 @@ import * as nestedProperty from 'nested-property'; import MiOS from './mios'; import { hostname } from './config'; +import { erase } from '../../prelude/array'; const defaultSettings = { home: null, @@ -195,7 +196,7 @@ export default (os: MiOS) => new Vuex.Store({ removeDeckColumn(state, id) { state.deck.columns = state.deck.columns.filter(c => c.id != id); - state.deck.layout = state.deck.layout.map(ids => ids.filter(x => x != id)); + state.deck.layout = state.deck.layout.map(ids => erase(id, ids)); state.deck.layout = state.deck.layout.filter(ids => ids.length > 0); }, @@ -266,7 +267,7 @@ export default (os: MiOS) => new Vuex.Store({ stackLeftDeckColumn(state, id) { const i = state.deck.layout.findIndex(ids => ids.indexOf(id) != -1); - state.deck.layout = state.deck.layout.map(ids => ids.filter(x => x != id)); + state.deck.layout = state.deck.layout.map(ids => erase(id, ids)); const left = state.deck.layout[i - 1]; if (left) state.deck.layout[i - 1].push(id); state.deck.layout = state.deck.layout.filter(ids => ids.length > 0); @@ -274,7 +275,7 @@ export default (os: MiOS) => new Vuex.Store({ popRightDeckColumn(state, id) { const i = state.deck.layout.findIndex(ids => ids.indexOf(id) != -1); - state.deck.layout = state.deck.layout.map(ids => ids.filter(x => x != id)); + state.deck.layout = state.deck.layout.map(ids => erase(id, ids)); state.deck.layout.splice(i + 1, 0, [id]); state.deck.layout = state.deck.layout.filter(ids => ids.length > 0); }, diff --git a/src/client/app/sw.js b/src/client/app/sw.js index ac7ea20acf..d381bfb7a5 100644 --- a/src/client/app/sw.js +++ b/src/client/app/sw.js @@ -3,6 +3,7 @@ */ import composeNotification from './common/scripts/compose-notification'; +import { erase } from '../../prelude/array'; // キャッシュするリソース const cachee = [ @@ -24,8 +25,7 @@ self.addEventListener('activate', ev => { // Clean up old caches ev.waitUntil( caches.keys().then(keys => Promise.all( - keys - .filter(key => key != _VERSION_) + erase(_VERSION_, keys) .map(key => caches.delete(key)) )) ); |