refactor(client): Do not mutate prop directly

Related #6595
This commit is contained in:
syuilo
2020-07-27 08:46:21 +09:00
parent b32737cdff
commit b5a1fdd4c7
5 changed files with 73 additions and 70 deletions

View File

@@ -74,10 +74,6 @@ export default (opts) => ({
},
methods: {
updateItem(i, item) {
Vue.set((this as any).items, i, item);
},
reload() {
this.items = [];
this.init();
@@ -94,6 +90,9 @@ export default (opts) => ({
...params,
limit: this.pagination.noPaging ? (this.pagination.limit || 10) : (this.pagination.limit || 10) + 1,
}).then(items => {
for (const item of items) {
Object.freeze(item);
}
if (!this.pagination.noPaging && (items.length > (this.pagination.limit || 10))) {
items.pop();
this.items = this.pagination.reversed ? [...items].reverse() : items;
@@ -130,6 +129,9 @@ export default (opts) => ({
untilId: this.items[this.items.length - 1].id,
}),
}).then(items => {
for (const item of items) {
Object.freeze(item);
}
if (items.length > SECOND_FETCH_LIMIT) {
items.pop();
this.items = this.pagination.reversed ? [...items].reverse().concat(this.items) : this.items.concat(items);