I've been trying to update the "views" of a discussion for the discussion-views extension.
Creating the modal, showing the modal and displaying the current views in the inputfield from the modal works.
The purpose when submitting the modal is that the "views" of the discussion will get changed to the value in the input field.
Although this isn't working. I'm not sure what to write in the save()
function from the discussion. I assume the database field and then the value to update that db value to.
onsubmit(e)
{
e.preventDefault();
this.loading = true;
const newViews = parseInt(this.newViewsCount());
const currentViews = this.currentViewsCount;
if (newViews >= 0 && newViews !== currentViews)
{
this.discussion.save({views: newViews})
.then(() => { m.redraw() })
.catch((reason) => { console.log(reason) });
//
// app.request({
// method: 'PATCH',
// url: app.forum.attribute('apiUrl') + this.discussion.apiEndpoint(),
// data: {views: newViews}
// });
// console.log();
}
this.hide();
}
I tried with app.request and with the normal save() but none of them is updating my view count of the discussion.