Fixes wrong total attachments variable when document is of type text or URL.

This commit is contained in:
Mateus Machado Luna 2019-08-22 11:41:16 -03:00
parent 719f8f3b1f
commit 628e96e09f
1 changed files with 1 additions and 1 deletions

View File

@ -210,7 +210,7 @@ export const fetchAttachments = ({ commit }, { page, attachmentsPerPage, itemId,
axios.wp.get('/media/?parent=' + itemId + '&per_page=' + attachmentsPerPage + '&page=' + page)
.then(res => {
let attachments = res.data.filter((attachment) => attachment.id != documentId);
let total = documentId && res.headers['x-wp-total'] > 0 ? res.headers['x-wp-total'] - 1 : res.headers['x-wp-total'];
let total = (documentId && res.data.length != attachments.length && res.headers['x-wp-total'] > 0) ? res.headers['x-wp-total'] - 1 : res.headers['x-wp-total'];
commit('setAttachments', attachments);
commit('setTotalAttachments', total);