mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Favorite and unfavorite users for the anonymous user.
This commit is contained in:
parent
20053881f1
commit
cfab68ecd6
@ -83,6 +83,10 @@ public class FavoriteThing {
|
|||||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
String accessToken, SubscribedUserData subscribedUserData,
|
String accessToken, SubscribedUserData subscribedUserData,
|
||||||
FavoriteThingListener favoriteThingListener) {
|
FavoriteThingListener favoriteThingListener) {
|
||||||
|
if (accessToken == null) {
|
||||||
|
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase,
|
||||||
|
subscribedUserData, favoriteThingListener::success);
|
||||||
|
} else {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(APIUtils.SR_NAME_KEY, "u_" + subscribedUserData.getName());
|
params.put(APIUtils.SR_NAME_KEY, "u_" + subscribedUserData.getName());
|
||||||
params.put(APIUtils.MAKE_FAVORITE_KEY, "true");
|
params.put(APIUtils.MAKE_FAVORITE_KEY, "true");
|
||||||
@ -103,11 +107,16 @@ public class FavoriteThing {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void unfavoriteUser(Executor executor, Handler handler, Retrofit oauthRetrofit,
|
public static void unfavoriteUser(Executor executor, Handler handler, Retrofit oauthRetrofit,
|
||||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
String accessToken, SubscribedUserData subscribedUserData,
|
String accessToken, SubscribedUserData subscribedUserData,
|
||||||
FavoriteThingListener favoriteThingListener) {
|
FavoriteThingListener favoriteThingListener) {
|
||||||
|
if (accessToken == null) {
|
||||||
|
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase, subscribedUserData,
|
||||||
|
favoriteThingListener::success);
|
||||||
|
} else {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(APIUtils.SR_NAME_KEY, "u_" + subscribedUserData.getName());
|
params.put(APIUtils.SR_NAME_KEY, "u_" + subscribedUserData.getName());
|
||||||
params.put(APIUtils.MAKE_FAVORITE_KEY, "false");
|
params.put(APIUtils.MAKE_FAVORITE_KEY, "false");
|
||||||
@ -128,6 +137,7 @@ public class FavoriteThing {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public interface FavoriteThingListener {
|
public interface FavoriteThingListener {
|
||||||
void success();
|
void success();
|
||||||
|
Loading…
Reference in New Issue
Block a user