Update store.ts

This commit is contained in:
Acid Chicken (硫酸鶏) 2019-02-02 20:58:48 +09:00 committed by GitHub
parent 2a50997a75
commit 0aa50c6eea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -309,15 +309,17 @@ export default (os: MiOS) => new Vuex.Store({
}, },
stackLeftDeckColumn(state, id) { stackLeftDeckColumn(state, id) {
const i = state.deck.layout.findIndex(ids => ids.indexOf(id) != -1); const i = state.deck.layout.findIndex(ids => ~ids.indexOf(id));
state.deck.layout = state.deck.layout.map(ids => erase(id, ids)); if (i) {
const left = state.deck.layout[i - 1]; state.deck.layout = state.deck.layout.map(ids => erase(id, ids));
if (left) state.deck.layout[i - 1].push(id); const left = state.deck.layout[i - 1];
state.deck.layout = state.deck.layout.filter(ids => ids.length > 0); if (left) state.deck.layout[i - 1].push(id);
state.deck.layout = state.deck.layout.filter(ids => ids.length > 0);
}
}, },
popRightDeckColumn(state, id) { popRightDeckColumn(state, id) {
const i = state.deck.layout.findIndex(ids => ids.indexOf(id) != -1); const i = state.deck.layout.findIndex(ids => ~ids.indexOf(id));
state.deck.layout = state.deck.layout.map(ids => erase(id, ids)); state.deck.layout = state.deck.layout.map(ids => erase(id, ids));
state.deck.layout.splice(i + 1, 0, [id]); state.deck.layout.splice(i + 1, 0, [id]);
state.deck.layout = state.deck.layout.filter(ids => ids.length > 0); state.deck.layout = state.deck.layout.filter(ids => ids.length > 0);