Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 committed Feb 27, 2022
1 parent e608c61 commit bd34be9
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,32 @@ import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

<<<<<<< HEAD
=======
import 'package:immich_mobile/modules/search/services/search.service.dart';

>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
class SearchPageState {
final String searchTerm;
final bool isSearchEnabled;
final List<String> searchSuggestion;
<<<<<<< HEAD
=======
final List<String> userSuggestedSearchTerms;
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18

SearchPageState({
required this.searchTerm,
required this.isSearchEnabled,
required this.searchSuggestion,
<<<<<<< HEAD
=======
required this.userSuggestedSearchTerms,
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
});

SearchPageState copyWith({
String? searchTerm,
bool? isSearchEnabled,
List<String>? searchSuggestion,
<<<<<<< HEAD
=======
List<String>? userSuggestedSearchTerms,
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
}) {
return SearchPageState(
searchTerm: searchTerm ?? this.searchTerm,
isSearchEnabled: isSearchEnabled ?? this.isSearchEnabled,
searchSuggestion: searchSuggestion ?? this.searchSuggestion,
<<<<<<< HEAD
=======
userSuggestedSearchTerms: userSuggestedSearchTerms ?? this.userSuggestedSearchTerms,
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
);
}

Expand All @@ -52,10 +37,7 @@ class SearchPageState {
'searchTerm': searchTerm,
'isSearchEnabled': isSearchEnabled,
'searchSuggestion': searchSuggestion,
<<<<<<< HEAD
=======
'userSuggestedSearchTerms': userSuggestedSearchTerms,
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
};
}

Expand All @@ -64,10 +46,7 @@ class SearchPageState {
searchTerm: map['searchTerm'] ?? '',
isSearchEnabled: map['isSearchEnabled'] ?? false,
searchSuggestion: List<String>.from(map['searchSuggestion']),
<<<<<<< HEAD
=======
userSuggestedSearchTerms: List<String>.from(map['userSuggestedSearchTerms']),
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
);
}

Expand All @@ -76,14 +55,9 @@ class SearchPageState {
factory SearchPageState.fromJson(String source) => SearchPageState.fromMap(json.decode(source));

@override
<<<<<<< HEAD
String toString() =>
'SearchPageState(searchTerm: $searchTerm, isSearchEnabled: $isSearchEnabled, searchSuggestion: $searchSuggestion)';
=======
String toString() {
return 'SearchPageState(searchTerm: $searchTerm, isSearchEnabled: $isSearchEnabled, searchSuggestion: $searchSuggestion, userSuggestedSearchTerms: $userSuggestedSearchTerms)';
}
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18

@override
bool operator ==(Object other) {
Expand All @@ -93,13 +67,6 @@ class SearchPageState {
return other is SearchPageState &&
other.searchTerm == searchTerm &&
other.isSearchEnabled == isSearchEnabled &&
<<<<<<< HEAD
listEquals(other.searchSuggestion, searchSuggestion);
}

@override
int get hashCode => searchTerm.hashCode ^ isSearchEnabled.hashCode ^ searchSuggestion.hashCode;
=======
listEquals(other.searchSuggestion, searchSuggestion) &&
listEquals(other.userSuggestedSearchTerms, userSuggestedSearchTerms);
}
Expand All @@ -111,7 +78,6 @@ class SearchPageState {
searchSuggestion.hashCode ^
userSuggestedSearchTerms.hashCode;
}
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
}

class SearchPageStateNotifier extends StateNotifier<SearchPageState> {
Expand All @@ -121,18 +87,12 @@ class SearchPageStateNotifier extends StateNotifier<SearchPageState> {
searchTerm: "",
isSearchEnabled: false,
searchSuggestion: [],
<<<<<<< HEAD
),
);

=======
userSuggestedSearchTerms: [],
),
);

final SearchService _searchService = SearchService();

>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
void enableSearch() {
state = state.copyWith(isSearchEnabled: true);
}
Expand All @@ -148,11 +108,7 @@ class SearchPageStateNotifier extends StateNotifier<SearchPageState> {
}

void _getSearchSuggestion(String searchTerm) {
<<<<<<< HEAD
var searchList = ['January', '01 2022', 'feburary', "February", 'home', '3413'];
=======
var searchList = state.userSuggestedSearchTerms;
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18

var newList = searchList.where((e) => e.toLowerCase().contains(searchTerm));

Expand All @@ -162,15 +118,12 @@ class SearchPageStateNotifier extends StateNotifier<SearchPageState> {
state = state.copyWith(searchSuggestion: []);
}
}
<<<<<<< HEAD
=======

void getSuggestedSearchTerms() async {
var userSuggestedSearchTerms = await _searchService.getUserSuggestedSearchTerms();

state = state.copyWith(userSuggestedSearchTerms: userSuggestedSearchTerms);
}
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
}

final searchPageStateProvider = StateNotifierProvider<SearchPageStateNotifier, SearchPageState>((ref) {
Expand Down
3 changes: 0 additions & 3 deletions mobile/lib/modules/search/ui/search_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ class SearchBar extends HookConsumerWidget with PreferredSizeWidget {
focusNode: searchFocusNode,
autofocus: false,
onTap: () {
<<<<<<< HEAD
=======
ref.watch(searchPageStateProvider.notifier).getSuggestedSearchTerms();
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
ref.watch(searchPageStateProvider.notifier).enableSearch();
searchFocusNode.requestFocus();
},
Expand Down
7 changes: 0 additions & 7 deletions mobile/lib/modules/search/views/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@ class SearchPage extends HookConsumerWidget {
final isSearchEnabled = ref.watch(searchPageStateProvider).isSearchEnabled;

useEffect(() {
<<<<<<< HEAD
searchFocusNode = FocusNode();
return () {
searchFocusNode.dispose();
};
=======
print("search");
searchFocusNode = FocusNode();
return () => searchFocusNode.dispose();
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
}, []);

return Scaffold(
Expand Down

0 comments on commit bd34be9

Please sign in to comment.