Merge branch 'develop' into feat/v5-ui-redesign

This commit is contained in:
Sivin Varghese
2026-01-07 15:58:29 +05:30
committed by GitHub
55 changed files with 3976 additions and 387 deletions
@@ -57,8 +57,9 @@ export const actions = {
});
}
},
async fullSearch({ commit, dispatch }, { q }) {
if (!q) {
async fullSearch({ commit, dispatch }, payload) {
const { q, ...filters } = payload;
if (!q && !Object.keys(filters).length) {
return;
}
commit(types.FULL_SEARCH_SET_UI_FLAG, {
@@ -67,10 +68,10 @@ export const actions = {
});
try {
await Promise.all([
dispatch('contactSearch', { q }),
dispatch('conversationSearch', { q }),
dispatch('messageSearch', { q }),
dispatch('articleSearch', { q }),
dispatch('contactSearch', { q, ...filters }),
dispatch('conversationSearch', { q, ...filters }),
dispatch('messageSearch', { q, ...filters }),
dispatch('articleSearch', { q, ...filters }),
]);
} catch (error) {
// Ignore error
@@ -81,10 +82,11 @@ export const actions = {
});
}
},
async contactSearch({ commit }, { q, page = 1 }) {
async contactSearch({ commit }, payload) {
const { page = 1, ...searchParams } = payload;
commit(types.CONTACT_SEARCH_SET_UI_FLAG, { isFetching: true });
try {
const { data } = await SearchAPI.contacts({ q, page });
const { data } = await SearchAPI.contacts({ ...searchParams, page });
commit(types.CONTACT_SEARCH_SET, data.payload.contacts);
} catch (error) {
// Ignore error
@@ -92,10 +94,11 @@ export const actions = {
commit(types.CONTACT_SEARCH_SET_UI_FLAG, { isFetching: false });
}
},
async conversationSearch({ commit }, { q, page = 1 }) {
async conversationSearch({ commit }, payload) {
const { page = 1, ...searchParams } = payload;
commit(types.CONVERSATION_SEARCH_SET_UI_FLAG, { isFetching: true });
try {
const { data } = await SearchAPI.conversations({ q, page });
const { data } = await SearchAPI.conversations({ ...searchParams, page });
commit(types.CONVERSATION_SEARCH_SET, data.payload.conversations);
} catch (error) {
// Ignore error
@@ -103,10 +106,11 @@ export const actions = {
commit(types.CONVERSATION_SEARCH_SET_UI_FLAG, { isFetching: false });
}
},
async messageSearch({ commit }, { q, page = 1 }) {
async messageSearch({ commit }, payload) {
const { page = 1, ...searchParams } = payload;
commit(types.MESSAGE_SEARCH_SET_UI_FLAG, { isFetching: true });
try {
const { data } = await SearchAPI.messages({ q, page });
const { data } = await SearchAPI.messages({ ...searchParams, page });
commit(types.MESSAGE_SEARCH_SET, data.payload.messages);
} catch (error) {
// Ignore error
@@ -114,10 +118,11 @@ export const actions = {
commit(types.MESSAGE_SEARCH_SET_UI_FLAG, { isFetching: false });
}
},
async articleSearch({ commit }, { q, page = 1 }) {
async articleSearch({ commit }, payload) {
const { page = 1, ...searchParams } = payload;
commit(types.ARTICLE_SEARCH_SET_UI_FLAG, { isFetching: true });
try {
const { data } = await SearchAPI.articles({ q, page });
const { data } = await SearchAPI.articles({ ...searchParams, page });
commit(types.ARTICLE_SEARCH_SET, data.payload.articles);
} catch (error) {
// Ignore error
@@ -77,6 +77,16 @@ describe('#actions', () => {
expect(dispatch).toHaveBeenCalledWith('messageSearch', { q: 'test' });
expect(dispatch).toHaveBeenCalledWith('articleSearch', { q: 'test' });
});
it('should pass filters to all search actions including articleSearch', async () => {
const payload = { q: 'test', since: 1700000000, until: 1732000000 };
await actions.fullSearch({ commit, dispatch }, payload);
expect(dispatch).toHaveBeenCalledWith('contactSearch', payload);
expect(dispatch).toHaveBeenCalledWith('conversationSearch', payload);
expect(dispatch).toHaveBeenCalledWith('messageSearch', payload);
expect(dispatch).toHaveBeenCalledWith('articleSearch', payload);
});
});
describe('#contactSearch', () => {
@@ -165,6 +175,22 @@ describe('#actions', () => {
]);
});
it('should handle article search with date filters', async () => {
axios.get.mockResolvedValue({
data: { payload: { articles: [{ id: 1 }] } },
});
await actions.articleSearch(
{ commit },
{ q: 'test', page: 1, since: 1700000000, until: 1732000000 }
);
expect(commit.mock.calls).toEqual([
[types.ARTICLE_SEARCH_SET_UI_FLAG, { isFetching: true }],
[types.ARTICLE_SEARCH_SET, [{ id: 1 }]],
[types.ARTICLE_SEARCH_SET_UI_FLAG, { isFetching: false }],
]);
});
it('should handle failed article search', async () => {
axios.get.mockRejectedValue({});
await actions.articleSearch({ commit }, { q: 'test' });