laracasts/Lets-Build-a-Forum-in-Laravel

Paginator.vue issue with new reply

FHoulbreque opened this issue · 2 comments

Hello,

Your new component just created in the latest lesson introduced an issue.

When you create a reply (with pagination set to 1 reply), the reply show up on the page with the one previously shown (so 2 are displayed despite the pagination should only return one).

This issue it there as well when you delete a Reply leaving a blank page.

Maybe will we need inter-component event there to monitor new post and flush datas?

What would you think?

Thanks for this tut anyway.

I hacked your Collection.js file but it's only a quick fix as it don't show any clue about current update status, and if your local server is slow, it could lead to strange behaviour.

I just suggest this as it could make the user experience more agreeable.

Here's how I changed the file :

export default {
    data() {
        return {
            items: [],
        }
    },

    methods: {
        add(item) {
            // this.items.push(item);
            let page = Math.ceil((this.dataSet.total + 1) / this.dataSet.per_page);
            this.fetch(page);
            this.$emit('added');
        },
        remove(index) {
            // this.items.splice(index, 1);
            this.fetch(this.dataSet.current_page);
            this.$emit('removed');
        }
    }

}

I have just seen the same thing, and made a small .gif to show it:
r