[FIX] mail: prevent load messages if already loading
task-2373952 closes odoo/odoo#61424 X-original-commit: a4c737eb1d45610f6ab70268d5134dc5ed00ba8d Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -14,6 +14,12 @@ const {
|
||||
const Bus = require('web.Bus');
|
||||
const { makeTestPromise, file: { createFile, inputFiles } } = require('web.test_utils');
|
||||
|
||||
const {
|
||||
applyFilter,
|
||||
toggleAddCustomFilter,
|
||||
toggleFilterMenu,
|
||||
} = require('web.test_utils_control_panel');
|
||||
|
||||
QUnit.module('mail', {}, function () {
|
||||
QUnit.module('components', {}, function () {
|
||||
QUnit.module('discuss', {}, function () {
|
||||
@@ -4262,6 +4268,31 @@ QUnit.test('mark channel as seen if last message is visible when switching chann
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('add custom filter should filter messages accordingly to selected filter', async function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
this.data['mail.channel'].records.push({
|
||||
id: 20,
|
||||
name: "General"
|
||||
});
|
||||
await this.start({
|
||||
async mockRPC(route, args) {
|
||||
if (args.method === 'message_fetch') {
|
||||
const domainsAsStr = args.kwargs.domain.map(domain => domain.join(''));
|
||||
assert.step(`message_fetch:${domainsAsStr.join(',')}`);
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
assert.verifySteps(['message_fetch:needaction=true'], "A message_fetch request should have been done for needaction messages as inbox is selected by default");
|
||||
|
||||
// Open filter menu of control panel and select a custom filter (id = 0, the only one available)
|
||||
await toggleFilterMenu(document.body);
|
||||
await toggleAddCustomFilter(document.body);
|
||||
await applyFilter(document.body);
|
||||
assert.verifySteps(['message_fetch:id=0,needaction=true'], "A message_fetch request should have been done for selected filter & domain of current thread (inbox)");
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -203,13 +203,17 @@ function factory(dependencies) {
|
||||
if (!wasCacheRefreshRequested && this.threadViews.length === 0) {
|
||||
// don't load message that won't be used
|
||||
return false;
|
||||
}
|
||||
if (!wasCacheRefreshRequested && (this.isLoaded || this.isLoading)) {
|
||||
}
|
||||
if (this.isLoading) {
|
||||
// avoid duplicate RPC
|
||||
return false;
|
||||
}
|
||||
if (!wasCacheRefreshRequested && this.isLoaded) {
|
||||
// avoid duplicate RPC
|
||||
return false;
|
||||
}
|
||||
const isMainCache = this.thread.mainCache === this;
|
||||
if (isMainCache && (this.isLoaded || this.isLoading)) {
|
||||
if (isMainCache && this.isLoaded) {
|
||||
// Ignore request on the main cache if it is already loaded or
|
||||
// loading. Indeed the main cache is automatically sync with
|
||||
// server updates already, so there is never a need to refresh
|
||||
|
||||
Reference in New Issue
Block a user