From e75cd0b1ddfa2cdafa624b1a054b832d03fc71dd Mon Sep 17 00:00:00 2001 From: DatDang Date: Thu, 31 Oct 2024 15:46:02 +0700 Subject: [PATCH] fixup! TF-3235 Create seach emails in thread API, datasource and repository --- .../thread/data/network/thread_api.dart | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/features/thread/data/network/thread_api.dart b/lib/features/thread/data/network/thread_api.dart index 9ea7438dfd..9e8ba3be16 100644 --- a/lib/features/thread/data/network/thread_api.dart +++ b/lib/features/thread/data/network/thread_api.dart @@ -152,14 +152,31 @@ class ThreadAPI { } } - final searchSnippets = result.parse( - getSearchSnippetInvocation.methodCallId, - SearchSnippetGetResponse.fromJson); - - return SearchEmailsResponse( - emailList: emailResultList?.list, - state: emailResultList?.state, - searchSnippets: searchSnippets?.list); + try { + final searchSnippets = result.parse( + getSearchSnippetInvocation.methodCallId, + SearchSnippetGetResponse.fromJson); + + return SearchEmailsResponse( + emailList: emailResultList?.list, + state: emailResultList?.state, + searchSnippets: searchSnippets?.list); + } catch (_) { + final searchResultWithoutSnippets = await getAllEmail( + session, + accountId, + limit: limit, + position: position, + sort: sort, + filter: filter, + properties: properties + ); + + return SearchEmailsResponse( + searchSnippets: null, + emailList: searchResultWithoutSnippets.emailList, + state: searchResultWithoutSnippets.state); + } } Future getChanges(