Merge branch 'client-support-for-favourite' into 'main'
added client side recipe favouriting See merge request cse1105/2025-2026/teams/csep-team-76!31
This commit is contained in:
commit
118aaef93a
1 changed files with 27 additions and 5 deletions
|
|
@ -12,7 +12,8 @@ public class Config {
|
||||||
private List<Long> favourites = new ArrayList<>();
|
private List<Long> favourites = new ArrayList<>();
|
||||||
private List<String> shoppingList = new ArrayList<>();
|
private List<String> shoppingList = new ArrayList<>();
|
||||||
|
|
||||||
public Config(){}
|
public Config() {
|
||||||
|
}
|
||||||
|
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
|
|
@ -22,10 +23,6 @@ public class Config {
|
||||||
return shoppingList;
|
return shoppingList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Long> getFavourites() {
|
|
||||||
return favourites;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServerUrl() {
|
public String getServerUrl() {
|
||||||
return serverUrl;
|
return serverUrl;
|
||||||
}
|
}
|
||||||
|
|
@ -45,4 +42,29 @@ public class Config {
|
||||||
public void setShoppingList(List<String> shoppingList) {
|
public void setShoppingList(List<String> shoppingList) {
|
||||||
this.shoppingList = shoppingList;
|
this.shoppingList = shoppingList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// favourite helper
|
||||||
|
|
||||||
|
public List<Long> getFavourites() {
|
||||||
|
if (favourites == null) {
|
||||||
|
favourites = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
return favourites;
|
||||||
|
}
|
||||||
|
// to avoid null pointers.
|
||||||
|
|
||||||
|
public boolean isFavourite(long recipeId) {
|
||||||
|
return getFavourites().contains(recipeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFavourite(long recipeId) {
|
||||||
|
if (!getFavourites().contains(recipeId)) {
|
||||||
|
getFavourites().add(recipeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFavourite(long recipeId) {
|
||||||
|
getFavourites().remove(recipeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue