refactor: rename clip -> smart search (#6713)
This commit is contained in:
@@ -5,14 +5,14 @@ class SearchResultPageState {
|
||||
final bool isLoading;
|
||||
final bool isSuccess;
|
||||
final bool isError;
|
||||
final bool isClip;
|
||||
final bool isSmart;
|
||||
final List<Asset> searchResult;
|
||||
|
||||
SearchResultPageState({
|
||||
required this.isLoading,
|
||||
required this.isSuccess,
|
||||
required this.isError,
|
||||
required this.isClip,
|
||||
required this.isSmart,
|
||||
required this.searchResult,
|
||||
});
|
||||
|
||||
@@ -20,21 +20,21 @@ class SearchResultPageState {
|
||||
bool? isLoading,
|
||||
bool? isSuccess,
|
||||
bool? isError,
|
||||
bool? isClip,
|
||||
bool? isSmart,
|
||||
List<Asset>? searchResult,
|
||||
}) {
|
||||
return SearchResultPageState(
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
isSuccess: isSuccess ?? this.isSuccess,
|
||||
isError: isError ?? this.isError,
|
||||
isClip: isClip ?? this.isClip,
|
||||
isSmart: isSmart ?? this.isSmart,
|
||||
searchResult: searchResult ?? this.searchResult,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SearchresultPageState(isLoading: $isLoading, isSuccess: $isSuccess, isError: $isError, isClip: $isClip, searchResult: $searchResult)';
|
||||
return 'SearchresultPageState(isLoading: $isLoading, isSuccess: $isSuccess, isError: $isError, isSmart: $isSmart, searchResult: $searchResult)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -46,7 +46,7 @@ class SearchResultPageState {
|
||||
other.isLoading == isLoading &&
|
||||
other.isSuccess == isSuccess &&
|
||||
other.isError == isError &&
|
||||
other.isClip == isClip &&
|
||||
other.isSmart == isSmart &&
|
||||
listEquals(other.searchResult, searchResult);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class SearchResultPageState {
|
||||
return isLoading.hashCode ^
|
||||
isSuccess.hashCode ^
|
||||
isError.hashCode ^
|
||||
isClip.hashCode ^
|
||||
isSmart.hashCode ^
|
||||
searchResult.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ class SearchResultPageNotifier extends StateNotifier<SearchResultPageState> {
|
||||
isError: false,
|
||||
isLoading: true,
|
||||
isSuccess: false,
|
||||
isClip: false,
|
||||
isSmart: false,
|
||||
),
|
||||
);
|
||||
|
||||
final SearchService _searchService;
|
||||
|
||||
Future<void> search(String searchTerm, {bool clipEnable = true}) async {
|
||||
Future<void> search(String searchTerm, {bool smartSearch = true}) async {
|
||||
state = state.copyWith(
|
||||
searchResult: [],
|
||||
isError: false,
|
||||
@@ -28,10 +28,8 @@ class SearchResultPageNotifier extends StateNotifier<SearchResultPageState> {
|
||||
isSuccess: false,
|
||||
);
|
||||
|
||||
List<Asset>? assets = await _searchService.searchAsset(
|
||||
searchTerm,
|
||||
clipEnable: clipEnable,
|
||||
);
|
||||
List<Asset>? assets =
|
||||
await _searchService.searchAsset(searchTerm, smartSearch: smartSearch);
|
||||
|
||||
if (assets != null) {
|
||||
state = state.copyWith(
|
||||
@@ -39,7 +37,7 @@ class SearchResultPageNotifier extends StateNotifier<SearchResultPageState> {
|
||||
isError: false,
|
||||
isLoading: false,
|
||||
isSuccess: true,
|
||||
isClip: clipEnable,
|
||||
isSmart: smartSearch,
|
||||
);
|
||||
} else {
|
||||
state = state.copyWith(
|
||||
@@ -47,7 +45,7 @@ class SearchResultPageNotifier extends StateNotifier<SearchResultPageState> {
|
||||
isError: true,
|
||||
isLoading: false,
|
||||
isSuccess: false,
|
||||
isClip: clipEnable,
|
||||
isSmart: smartSearch,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -63,7 +61,7 @@ final searchRenderListProvider = Provider((ref) {
|
||||
final result = ref.watch(searchResultPageProvider);
|
||||
return ref.watch(
|
||||
renderListProviderWithGrouping(
|
||||
(result.searchResult, result.isClip ? GroupAssetsBy.none : null),
|
||||
(result.searchResult, result.isSmart ? GroupAssetsBy.none : null),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -31,13 +31,13 @@ class SearchService {
|
||||
|
||||
Future<List<Asset>?> searchAsset(
|
||||
String searchTerm, {
|
||||
bool clipEnable = true,
|
||||
bool smartSearch = true,
|
||||
}) async {
|
||||
// TODO search in local DB: 1. when offline, 2. to find local assets
|
||||
try {
|
||||
final SearchResponseDto? results = await _apiService.searchApi.search(
|
||||
query: searchTerm,
|
||||
clip: clipEnable,
|
||||
smart: smartSearch,
|
||||
);
|
||||
if (results == null) {
|
||||
return null;
|
||||
|
||||
@@ -11,17 +11,17 @@ import 'package:immich_mobile/shared/ui/asset_grid/multiselect_grid.dart';
|
||||
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
|
||||
|
||||
class SearchType {
|
||||
SearchType({required this.isClip, required this.searchTerm});
|
||||
SearchType({required this.isSmart, required this.searchTerm});
|
||||
|
||||
final bool isClip;
|
||||
final bool isSmart;
|
||||
final String searchTerm;
|
||||
}
|
||||
|
||||
SearchType _getSearchType(String searchTerm) {
|
||||
if (searchTerm.startsWith('m:')) {
|
||||
return SearchType(isClip: false, searchTerm: searchTerm.substring(2));
|
||||
return SearchType(isSmart: false, searchTerm: searchTerm.substring(2));
|
||||
} else {
|
||||
return SearchType(isClip: true, searchTerm: searchTerm);
|
||||
return SearchType(isSmart: true, searchTerm: searchTerm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class SearchResultPage extends HookConsumerWidget {
|
||||
Duration.zero,
|
||||
() => ref
|
||||
.read(searchResultPageProvider.notifier)
|
||||
.search(searchType.searchTerm, clipEnable: searchType.isClip),
|
||||
.search(searchType.searchTerm, smartSearch: searchType.isSmart),
|
||||
);
|
||||
return () => searchFocusNode?.dispose();
|
||||
},
|
||||
@@ -67,7 +67,7 @@ class SearchResultPage extends HookConsumerWidget {
|
||||
var searchType = _getSearchType(newSearchTerm);
|
||||
return ref
|
||||
.watch(searchResultPageProvider.notifier)
|
||||
.search(searchType.searchTerm, clipEnable: searchType.isClip);
|
||||
.search(searchType.searchTerm, smartSearch: searchType.isSmart);
|
||||
}
|
||||
|
||||
buildTextField() {
|
||||
|
||||
Generated
+6
-4
@@ -66,7 +66,7 @@ This endpoint does not need any parameter.
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **search**
|
||||
> SearchResponseDto search(clip, motion, q, query, recent, type, withArchived)
|
||||
> SearchResponseDto search(clip, motion, q, query, recent, smart, type, withArchived)
|
||||
|
||||
|
||||
|
||||
@@ -89,16 +89,17 @@ import 'package:openapi/api.dart';
|
||||
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);
|
||||
|
||||
final api_instance = SearchApi();
|
||||
final clip = true; // bool |
|
||||
final clip = true; // bool | @deprecated
|
||||
final motion = true; // bool |
|
||||
final q = q_example; // String |
|
||||
final query = query_example; // String |
|
||||
final recent = true; // bool |
|
||||
final smart = true; // bool |
|
||||
final type = type_example; // String |
|
||||
final withArchived = true; // bool |
|
||||
|
||||
try {
|
||||
final result = api_instance.search(clip, motion, q, query, recent, type, withArchived);
|
||||
final result = api_instance.search(clip, motion, q, query, recent, smart, type, withArchived);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling SearchApi->search: $e\n');
|
||||
@@ -109,11 +110,12 @@ try {
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**clip** | **bool**| | [optional]
|
||||
**clip** | **bool**| @deprecated | [optional]
|
||||
**motion** | **bool**| | [optional]
|
||||
**q** | **String**| | [optional]
|
||||
**query** | **String**| | [optional]
|
||||
**recent** | **bool**| | [optional]
|
||||
**smart** | **bool**| | [optional]
|
||||
**type** | **String**| | [optional]
|
||||
**withArchived** | **bool**| | [optional]
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -8,7 +8,6 @@ import 'package:openapi/api.dart';
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**clipEncode** | **bool** | |
|
||||
**configFile** | **bool** | |
|
||||
**facialRecognition** | **bool** | |
|
||||
**map** | **bool** | |
|
||||
@@ -18,6 +17,7 @@ Name | Type | Description | Notes
|
||||
**reverseGeocoding** | **bool** | |
|
||||
**search** | **bool** | |
|
||||
**sidecar** | **bool** | |
|
||||
**smartSearch** | **bool** | |
|
||||
**trash** | **bool** | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
Generated
+12
-3
@@ -64,6 +64,7 @@ class SearchApi {
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [bool] clip:
|
||||
/// @deprecated
|
||||
///
|
||||
/// * [bool] motion:
|
||||
///
|
||||
@@ -73,10 +74,12 @@ class SearchApi {
|
||||
///
|
||||
/// * [bool] recent:
|
||||
///
|
||||
/// * [bool] smart:
|
||||
///
|
||||
/// * [String] type:
|
||||
///
|
||||
/// * [bool] withArchived:
|
||||
Future<Response> searchWithHttpInfo({ bool? clip, bool? motion, String? q, String? query, bool? recent, String? type, bool? withArchived, }) async {
|
||||
Future<Response> searchWithHttpInfo({ bool? clip, bool? motion, String? q, String? query, bool? recent, bool? smart, String? type, bool? withArchived, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/search';
|
||||
|
||||
@@ -102,6 +105,9 @@ class SearchApi {
|
||||
if (recent != null) {
|
||||
queryParams.addAll(_queryParams('', 'recent', recent));
|
||||
}
|
||||
if (smart != null) {
|
||||
queryParams.addAll(_queryParams('', 'smart', smart));
|
||||
}
|
||||
if (type != null) {
|
||||
queryParams.addAll(_queryParams('', 'type', type));
|
||||
}
|
||||
@@ -126,6 +132,7 @@ class SearchApi {
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [bool] clip:
|
||||
/// @deprecated
|
||||
///
|
||||
/// * [bool] motion:
|
||||
///
|
||||
@@ -135,11 +142,13 @@ class SearchApi {
|
||||
///
|
||||
/// * [bool] recent:
|
||||
///
|
||||
/// * [bool] smart:
|
||||
///
|
||||
/// * [String] type:
|
||||
///
|
||||
/// * [bool] withArchived:
|
||||
Future<SearchResponseDto?> search({ bool? clip, bool? motion, String? q, String? query, bool? recent, String? type, bool? withArchived, }) async {
|
||||
final response = await searchWithHttpInfo( clip: clip, motion: motion, q: q, query: query, recent: recent, type: type, withArchived: withArchived, );
|
||||
Future<SearchResponseDto?> search({ bool? clip, bool? motion, String? q, String? query, bool? recent, bool? smart, String? type, bool? withArchived, }) async {
|
||||
final response = await searchWithHttpInfo( clip: clip, motion: motion, q: q, query: query, recent: recent, smart: smart, type: type, withArchived: withArchived, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
|
||||
+9
-9
@@ -13,7 +13,6 @@ part of openapi.api;
|
||||
class ServerFeaturesDto {
|
||||
/// Returns a new [ServerFeaturesDto] instance.
|
||||
ServerFeaturesDto({
|
||||
required this.clipEncode,
|
||||
required this.configFile,
|
||||
required this.facialRecognition,
|
||||
required this.map,
|
||||
@@ -23,11 +22,10 @@ class ServerFeaturesDto {
|
||||
required this.reverseGeocoding,
|
||||
required this.search,
|
||||
required this.sidecar,
|
||||
required this.smartSearch,
|
||||
required this.trash,
|
||||
});
|
||||
|
||||
bool clipEncode;
|
||||
|
||||
bool configFile;
|
||||
|
||||
bool facialRecognition;
|
||||
@@ -46,11 +44,12 @@ class ServerFeaturesDto {
|
||||
|
||||
bool sidecar;
|
||||
|
||||
bool smartSearch;
|
||||
|
||||
bool trash;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is ServerFeaturesDto &&
|
||||
other.clipEncode == clipEncode &&
|
||||
other.configFile == configFile &&
|
||||
other.facialRecognition == facialRecognition &&
|
||||
other.map == map &&
|
||||
@@ -60,12 +59,12 @@ class ServerFeaturesDto {
|
||||
other.reverseGeocoding == reverseGeocoding &&
|
||||
other.search == search &&
|
||||
other.sidecar == sidecar &&
|
||||
other.smartSearch == smartSearch &&
|
||||
other.trash == trash;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(clipEncode.hashCode) +
|
||||
(configFile.hashCode) +
|
||||
(facialRecognition.hashCode) +
|
||||
(map.hashCode) +
|
||||
@@ -75,14 +74,14 @@ class ServerFeaturesDto {
|
||||
(reverseGeocoding.hashCode) +
|
||||
(search.hashCode) +
|
||||
(sidecar.hashCode) +
|
||||
(smartSearch.hashCode) +
|
||||
(trash.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'ServerFeaturesDto[clipEncode=$clipEncode, configFile=$configFile, facialRecognition=$facialRecognition, map=$map, oauth=$oauth, oauthAutoLaunch=$oauthAutoLaunch, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, search=$search, sidecar=$sidecar, trash=$trash]';
|
||||
String toString() => 'ServerFeaturesDto[configFile=$configFile, facialRecognition=$facialRecognition, map=$map, oauth=$oauth, oauthAutoLaunch=$oauthAutoLaunch, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, search=$search, sidecar=$sidecar, smartSearch=$smartSearch, trash=$trash]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'clipEncode'] = this.clipEncode;
|
||||
json[r'configFile'] = this.configFile;
|
||||
json[r'facialRecognition'] = this.facialRecognition;
|
||||
json[r'map'] = this.map;
|
||||
@@ -92,6 +91,7 @@ class ServerFeaturesDto {
|
||||
json[r'reverseGeocoding'] = this.reverseGeocoding;
|
||||
json[r'search'] = this.search;
|
||||
json[r'sidecar'] = this.sidecar;
|
||||
json[r'smartSearch'] = this.smartSearch;
|
||||
json[r'trash'] = this.trash;
|
||||
return json;
|
||||
}
|
||||
@@ -104,7 +104,6 @@ class ServerFeaturesDto {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return ServerFeaturesDto(
|
||||
clipEncode: mapValueOfType<bool>(json, r'clipEncode')!,
|
||||
configFile: mapValueOfType<bool>(json, r'configFile')!,
|
||||
facialRecognition: mapValueOfType<bool>(json, r'facialRecognition')!,
|
||||
map: mapValueOfType<bool>(json, r'map')!,
|
||||
@@ -114,6 +113,7 @@ class ServerFeaturesDto {
|
||||
reverseGeocoding: mapValueOfType<bool>(json, r'reverseGeocoding')!,
|
||||
search: mapValueOfType<bool>(json, r'search')!,
|
||||
sidecar: mapValueOfType<bool>(json, r'sidecar')!,
|
||||
smartSearch: mapValueOfType<bool>(json, r'smartSearch')!,
|
||||
trash: mapValueOfType<bool>(json, r'trash')!,
|
||||
);
|
||||
}
|
||||
@@ -162,7 +162,6 @@ class ServerFeaturesDto {
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'clipEncode',
|
||||
'configFile',
|
||||
'facialRecognition',
|
||||
'map',
|
||||
@@ -172,6 +171,7 @@ class ServerFeaturesDto {
|
||||
'reverseGeocoding',
|
||||
'search',
|
||||
'sidecar',
|
||||
'smartSearch',
|
||||
'trash',
|
||||
};
|
||||
}
|
||||
|
||||
Generated
+1
-1
@@ -22,7 +22,7 @@ void main() {
|
||||
// TODO
|
||||
});
|
||||
|
||||
//Future<SearchResponseDto> search({ bool clip, bool motion, String q, String query, bool recent, String type, bool withArchived }) async
|
||||
//Future<SearchResponseDto> search({ bool clip, bool motion, String q, String query, bool recent, bool smart, String type, bool withArchived }) async
|
||||
test('test search', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
+5
-5
@@ -16,11 +16,6 @@ void main() {
|
||||
// final instance = ServerFeaturesDto();
|
||||
|
||||
group('test ServerFeaturesDto', () {
|
||||
// bool clipEncode
|
||||
test('to test the property `clipEncode`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// bool configFile
|
||||
test('to test the property `configFile`', () async {
|
||||
// TODO
|
||||
@@ -66,6 +61,11 @@ void main() {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// bool smartSearch
|
||||
test('to test the property `smartSearch`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// bool trash
|
||||
test('to test the property `trash`', () async {
|
||||
// TODO
|
||||
|
||||
Reference in New Issue
Block a user