mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-23 05:16:58 +00:00
Interchange GraphQLService and GraphQLRepository names.
This commit is contained in:
parent
2a0295e325
commit
69b685ae0d
@ -58,7 +58,7 @@ import awais.instagrabber.utils.TextUtils.shortcodeToId
|
||||
import awais.instagrabber.utils.emoji.EmojiParser
|
||||
import awais.instagrabber.viewmodels.AppStateViewModel
|
||||
import awais.instagrabber.viewmodels.DirectInboxViewModel
|
||||
import awais.instagrabber.webservices.GraphQLService
|
||||
import awais.instagrabber.webservices.GraphQLRepository
|
||||
import awais.instagrabber.webservices.MediaRepository
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.appbar.AppBarLayout.ScrollingViewBehavior
|
||||
@ -638,7 +638,7 @@ class MainActivity : BaseLanguageActivity(), FragmentManager.OnBackStackChangedL
|
||||
alertDialog.show()
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val media = if (isLoggedIn) mediaRepository.fetch(shortcodeToId(shortCode)) else GraphQLService.fetchPost(shortCode)
|
||||
val media = if (isLoggedIn) mediaRepository.fetch(shortcodeToId(shortCode)) else GraphQLRepository.fetchPost(shortCode)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (media == null) {
|
||||
Toast.makeText(applicationContext, R.string.post_not_found, Toast.LENGTH_SHORT).show()
|
||||
|
@ -8,14 +8,14 @@ import awais.instagrabber.repositories.responses.Hashtag;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.PostsFetchResponse;
|
||||
import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.TagsService;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
public class HashtagPostFetchService implements PostFetcher.PostFetchService {
|
||||
private final TagsService tagsService;
|
||||
private final GraphQLService graphQLService;
|
||||
private final GraphQLRepository graphQLRepository;
|
||||
private final Hashtag hashtagModel;
|
||||
private String nextMaxId;
|
||||
private boolean moreAvailable;
|
||||
@ -25,7 +25,7 @@ public class HashtagPostFetchService implements PostFetcher.PostFetchService {
|
||||
this.hashtagModel = hashtagModel;
|
||||
this.isLoggedIn = isLoggedIn;
|
||||
tagsService = isLoggedIn ? TagsService.getInstance() : null;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
graphQLRepository = isLoggedIn ? null : GraphQLRepository.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,7 +50,7 @@ public class HashtagPostFetchService implements PostFetcher.PostFetchService {
|
||||
}
|
||||
};
|
||||
if (isLoggedIn) tagsService.fetchPosts(hashtagModel.getName().toLowerCase(), nextMaxId, cb);
|
||||
else graphQLService.fetchHashtagPosts(
|
||||
else graphQLRepository.fetchHashtagPosts(
|
||||
hashtagModel.getName().toLowerCase(),
|
||||
nextMaxId,
|
||||
CoroutineUtilsKt.getContinuation((postsFetchResponse, throwable) -> {
|
||||
|
@ -8,14 +8,14 @@ import awais.instagrabber.repositories.responses.Location;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.PostsFetchResponse;
|
||||
import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.LocationService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
public class LocationPostFetchService implements PostFetcher.PostFetchService {
|
||||
private final LocationService locationService;
|
||||
private final GraphQLService graphQLService;
|
||||
private final GraphQLRepository graphQLRepository;
|
||||
private final Location locationModel;
|
||||
private String nextMaxId;
|
||||
private boolean moreAvailable;
|
||||
@ -25,7 +25,7 @@ public class LocationPostFetchService implements PostFetcher.PostFetchService {
|
||||
this.locationModel = locationModel;
|
||||
this.isLoggedIn = isLoggedIn;
|
||||
locationService = isLoggedIn ? LocationService.getInstance() : null;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
graphQLRepository = isLoggedIn ? null : GraphQLRepository.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,7 +50,7 @@ public class LocationPostFetchService implements PostFetcher.PostFetchService {
|
||||
}
|
||||
};
|
||||
if (isLoggedIn) locationService.fetchPosts(locationModel.getPk(), nextMaxId, cb);
|
||||
else graphQLService.fetchLocationPosts(
|
||||
else graphQLRepository.fetchLocationPosts(
|
||||
locationModel.getPk(),
|
||||
nextMaxId,
|
||||
CoroutineUtilsKt.getContinuation((postsFetchResponse, throwable) -> {
|
||||
|
@ -8,7 +8,7 @@ import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.PostsFetchResponse;
|
||||
import awais.instagrabber.repositories.responses.User;
|
||||
import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.ProfileService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
@ -16,7 +16,7 @@ import kotlinx.coroutines.Dispatchers;
|
||||
public class ProfilePostFetchService implements PostFetcher.PostFetchService {
|
||||
private static final String TAG = "ProfilePostFetchService";
|
||||
private final ProfileService profileService;
|
||||
private final GraphQLService graphQLService;
|
||||
private final GraphQLRepository graphQLRepository;
|
||||
private final User profileModel;
|
||||
private final boolean isLoggedIn;
|
||||
private String nextMaxId;
|
||||
@ -25,7 +25,7 @@ public class ProfilePostFetchService implements PostFetcher.PostFetchService {
|
||||
public ProfilePostFetchService(final User profileModel, final boolean isLoggedIn) {
|
||||
this.profileModel = profileModel;
|
||||
this.isLoggedIn = isLoggedIn;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
graphQLRepository = isLoggedIn ? null : GraphQLRepository.INSTANCE;
|
||||
profileService = isLoggedIn ? ProfileService.getInstance() : null;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class ProfilePostFetchService implements PostFetcher.PostFetchService {
|
||||
}
|
||||
};
|
||||
if (isLoggedIn) profileService.fetchPosts(profileModel.getPk(), nextMaxId, cb);
|
||||
else graphQLService.fetchProfilePosts(
|
||||
else graphQLRepository.fetchProfilePosts(
|
||||
profileModel.getPk(),
|
||||
30,
|
||||
nextMaxId,
|
||||
|
@ -8,14 +8,14 @@ import awais.instagrabber.models.enums.PostItemType;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.PostsFetchResponse;
|
||||
import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.ProfileService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
public class SavedPostFetchService implements PostFetcher.PostFetchService {
|
||||
private final ProfileService profileService;
|
||||
private final GraphQLService graphQLService;
|
||||
private final GraphQLRepository graphQLRepository;
|
||||
private final long profileId;
|
||||
private final PostItemType type;
|
||||
private final boolean isLoggedIn;
|
||||
@ -29,7 +29,7 @@ public class SavedPostFetchService implements PostFetcher.PostFetchService {
|
||||
this.type = type;
|
||||
this.isLoggedIn = isLoggedIn;
|
||||
this.collectionId = collectionId;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
graphQLRepository = isLoggedIn ? null : GraphQLRepository.INSTANCE;
|
||||
profileService = isLoggedIn ? ProfileService.getInstance() : null;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public class SavedPostFetchService implements PostFetcher.PostFetchService {
|
||||
break;
|
||||
case TAGGED:
|
||||
if (isLoggedIn) profileService.fetchTagged(profileId, nextMaxId, callback);
|
||||
else graphQLService.fetchTaggedPosts(
|
||||
else graphQLRepository.fetchTaggedPosts(
|
||||
profileId,
|
||||
30,
|
||||
nextMaxId,
|
||||
|
@ -67,7 +67,7 @@ import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.utils.DownloadUtils;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import awais.instagrabber.webservices.TagsService;
|
||||
@ -96,7 +96,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private StoriesRepository storiesRepository;
|
||||
private boolean isLoggedIn;
|
||||
private TagsService tagsService;
|
||||
private GraphQLService graphQLService;
|
||||
private GraphQLRepository graphQLRepository;
|
||||
private boolean storiesFetching;
|
||||
private Set<Media> selectedFeedModels;
|
||||
private Media downloadFeedModel;
|
||||
@ -218,7 +218,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
if (TextUtils.isEmpty(user.getUsername())) {
|
||||
// this only happens for anons
|
||||
opening = true;
|
||||
graphQLService.fetchPost(feedModel.getCode(), CoroutineUtilsKt.getContinuation((media, throwable) -> {
|
||||
graphQLRepository.fetchPost(feedModel.getCode(), CoroutineUtilsKt.getContinuation((media, throwable) -> {
|
||||
opening = false;
|
||||
if (throwable != null) {
|
||||
Log.e(TAG, "Error", throwable);
|
||||
@ -299,7 +299,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0;
|
||||
tagsService = isLoggedIn ? TagsService.getInstance() : null;
|
||||
storiesRepository = isLoggedIn ? StoriesRepository.Companion.getInstance() : null;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
graphQLRepository = isLoggedIn ? null : GraphQLRepository.INSTANCE;
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private void fetchHashtagModel() {
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
if (isLoggedIn) tagsService.fetch(hashtag, cb);
|
||||
else graphQLService.fetchTag(hashtag, CoroutineUtilsKt.getContinuation((hashtag1, throwable) -> {
|
||||
else graphQLRepository.fetchTag(hashtag, CoroutineUtilsKt.getContinuation((hashtag1, throwable) -> {
|
||||
if (throwable != null) {
|
||||
cb.onFailure(throwable);
|
||||
return;
|
||||
|
@ -30,7 +30,7 @@ import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.CookieUtils;
|
||||
import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.MediaRepository;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
@ -43,7 +43,7 @@ public final class LikesViewerFragment extends BottomSheetDialogFragment impleme
|
||||
private FragmentLikesBinding binding;
|
||||
private RecyclerLazyLoader lazyLoader;
|
||||
private MediaRepository mediaRepository;
|
||||
private GraphQLService graphQLService;
|
||||
private GraphQLRepository graphQLRepository;
|
||||
private boolean isLoggedIn;
|
||||
private String postId, endCursor;
|
||||
private boolean isComment;
|
||||
@ -113,7 +113,7 @@ public final class LikesViewerFragment extends BottomSheetDialogFragment impleme
|
||||
final String csrfToken = CookieUtils.getCsrfTokenFromCookie(cookie);
|
||||
if (csrfToken == null) return;
|
||||
mediaRepository = isLoggedIn ? MediaRepository.Companion.getInstance() : null;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
graphQLRepository = isLoggedIn ? null : GraphQLRepository.INSTANCE;
|
||||
// setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ public final class LikesViewerFragment extends BottomSheetDialogFragment impleme
|
||||
public void onRefresh() {
|
||||
if (isComment && !isLoggedIn) {
|
||||
lazyLoader.resetState();
|
||||
graphQLService.fetchCommentLikers(
|
||||
graphQLRepository.fetchCommentLikers(
|
||||
postId,
|
||||
null,
|
||||
CoroutineUtilsKt.getContinuation((response, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
@ -175,7 +175,7 @@ public final class LikesViewerFragment extends BottomSheetDialogFragment impleme
|
||||
binding.rvLikes.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.HORIZONTAL));
|
||||
lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
|
||||
if (!TextUtils.isEmpty(endCursor)) {
|
||||
graphQLService.fetchCommentLikers(
|
||||
graphQLRepository.fetchCommentLikers(
|
||||
postId,
|
||||
endCursor,
|
||||
CoroutineUtilsKt.getContinuation((response, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
|
@ -63,7 +63,7 @@ import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.utils.DownloadUtils;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.LocationService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
@ -88,7 +88,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
private Location locationModel;
|
||||
private ActionMode actionMode;
|
||||
private StoriesRepository storiesRepository;
|
||||
private GraphQLService graphQLService;
|
||||
private GraphQLRepository graphQLRepository;
|
||||
private LocationService locationService;
|
||||
private boolean isLoggedIn;
|
||||
private boolean storiesFetching;
|
||||
@ -208,7 +208,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
if (user == null) return;
|
||||
if (TextUtils.isEmpty(user.getUsername())) {
|
||||
opening = true;
|
||||
graphQLService.fetchPost(
|
||||
graphQLRepository.fetchPost(
|
||||
feedModel.getCode(),
|
||||
CoroutineUtilsKt.getContinuation((media, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
opening = false;
|
||||
@ -292,7 +292,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0;
|
||||
locationService = isLoggedIn ? LocationService.getInstance() : null;
|
||||
storiesRepository = StoriesRepository.Companion.getInstance();
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
graphQLRepository = isLoggedIn ? null : GraphQLRepository.INSTANCE;
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@ -400,7 +400,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
private void fetchLocationModel() {
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
if (isLoggedIn) locationService.fetch(locationId, cb);
|
||||
else graphQLService.fetchLocation(
|
||||
else graphQLRepository.fetchLocation(
|
||||
locationId,
|
||||
CoroutineUtilsKt.getContinuation((location, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
|
@ -93,7 +93,7 @@ import awais.instagrabber.viewmodels.ProfileFragmentViewModel;
|
||||
import awais.instagrabber.viewmodels.ProfileFragmentViewModelFactory;
|
||||
import awais.instagrabber.webservices.DirectMessagesService;
|
||||
import awais.instagrabber.webservices.FriendshipRepository;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.MediaRepository;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
@ -122,7 +122,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private StoriesRepository storiesRepository;
|
||||
private MediaRepository mediaRepository;
|
||||
private UserRepository userRepository;
|
||||
private GraphQLService graphQLService;
|
||||
private GraphQLRepository graphQLRepository;
|
||||
private DirectMessagesService directMessagesService;
|
||||
private boolean shouldRefresh = true;
|
||||
private boolean hasStories = false;
|
||||
@ -338,7 +338,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
storiesRepository = isLoggedIn ? StoriesRepository.Companion.getInstance() : null;
|
||||
mediaRepository = isLoggedIn ? MediaRepository.Companion.getInstance() : null;
|
||||
userRepository = isLoggedIn ? UserRepository.Companion.getInstance() : null;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
graphQLRepository = isLoggedIn ? null : GraphQLRepository.INSTANCE;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
accountRepository = AccountRepository.getInstance(AccountDataSource.getInstance(context));
|
||||
@ -669,7 +669,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
);
|
||||
return;
|
||||
}
|
||||
graphQLService.fetchUser(
|
||||
graphQLRepository.fetchUser(
|
||||
usernameTemp,
|
||||
CoroutineUtilsKt.getContinuation((user, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
|
@ -4,7 +4,7 @@ import retrofit2.http.GET
|
||||
import retrofit2.http.Path
|
||||
import retrofit2.http.QueryMap
|
||||
|
||||
interface GraphQLRepository {
|
||||
interface GraphQLService {
|
||||
@GET("/graphql/query/")
|
||||
suspend fun fetch(@QueryMap(encoded = true) queryParams: Map<String, String>): String
|
||||
|
@ -33,7 +33,7 @@ import awais.instagrabber.utils.CookieUtils;
|
||||
import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.webservices.CommentService;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.GraphQLRepository;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import kotlin.coroutines.Continuation;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
@ -48,7 +48,7 @@ public class CommentsViewerViewModel extends ViewModel {
|
||||
private final MutableLiveData<Resource<List<Comment>>> rootList = new MutableLiveData<>();
|
||||
private final MutableLiveData<Integer> rootCount = new MutableLiveData<>(0);
|
||||
private final MutableLiveData<Resource<List<Comment>>> replyList = new MutableLiveData<>();
|
||||
private final GraphQLService graphQLService;
|
||||
private final GraphQLRepository graphQLRepository;
|
||||
|
||||
private String shortCode;
|
||||
private String postId;
|
||||
@ -121,7 +121,7 @@ public class CommentsViewerViewModel extends ViewModel {
|
||||
};
|
||||
|
||||
public CommentsViewerViewModel() {
|
||||
graphQLService = GraphQLService.INSTANCE;
|
||||
graphQLRepository = GraphQLRepository.INSTANCE;
|
||||
final String cookie = settingsHelper.getString(Constants.COOKIE);
|
||||
final String deviceUuid = Utils.settingsHelper.getString(Constants.DEVICE_UUID);
|
||||
final String csrfToken = CookieUtils.getCsrfTokenFromCookie(cookie);
|
||||
@ -173,7 +173,7 @@ public class CommentsViewerViewModel extends ViewModel {
|
||||
commentService.fetchComments(postId, rootCursor, ccb);
|
||||
return;
|
||||
}
|
||||
graphQLService.fetchComments(
|
||||
graphQLRepository.fetchComments(
|
||||
shortCode,
|
||||
true,
|
||||
rootCursor,
|
||||
@ -202,7 +202,7 @@ public class CommentsViewerViewModel extends ViewModel {
|
||||
commentService.fetchChildComments(postId, commentId, repliesCursor, rcb);
|
||||
return;
|
||||
}
|
||||
graphQLService.fetchComments(commentId, false, repliesCursor, enqueueRequest(false, commentId, rcb));
|
||||
graphQLRepository.fetchComments(commentId, false, repliesCursor, enqueueRequest(false, commentId, rcb));
|
||||
}
|
||||
|
||||
private Continuation<String> enqueueRequest(final boolean root,
|
||||
|
@ -2,7 +2,7 @@ package awais.instagrabber.webservices
|
||||
|
||||
import android.util.Log
|
||||
import awais.instagrabber.models.enums.FollowingType
|
||||
import awais.instagrabber.repositories.GraphQLRepository
|
||||
import awais.instagrabber.repositories.GraphQLService
|
||||
import awais.instagrabber.repositories.responses.*
|
||||
import awais.instagrabber.utils.Constants
|
||||
import awais.instagrabber.utils.ResponseBodyUtils
|
||||
@ -12,8 +12,8 @@ import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
|
||||
object GraphQLService {
|
||||
private val repository: GraphQLRepository = retrofitWeb.create(GraphQLRepository::class.java)
|
||||
object GraphQLRepository {
|
||||
private val service: GraphQLService = retrofitWeb.create(GraphQLService::class.java)
|
||||
|
||||
// TODO convert string response to a response class
|
||||
private suspend fun fetch(
|
||||
@ -27,7 +27,7 @@ object GraphQLService {
|
||||
"query_hash" to queryHash,
|
||||
"variables" to variables,
|
||||
)
|
||||
val response = repository.fetch(queryMap)
|
||||
val response = service.fetch(queryMap)
|
||||
return parsePostResponse(response, arg1, arg2, backup)
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ object GraphQLService {
|
||||
"query_hash" to "5f0b1f6281e72053cbc07909c8d154ae",
|
||||
"variables" to "{\"comment_id\":\"" + commentId + "\"," + "\"first\":30," + "\"after\":\"" + (endCursor ?: "") + "\"}"
|
||||
)
|
||||
val response = repository.fetch(queryMap)
|
||||
val response = service.fetch(queryMap)
|
||||
val body = JSONObject(response)
|
||||
val status = body.getString("status")
|
||||
val data = body.getJSONObject("data").getJSONObject("comment").getJSONObject("edge_liked_by")
|
||||
@ -171,14 +171,14 @@ object GraphQLService {
|
||||
"query_hash" to if (root) "bc3296d1ce80a24b1b6e40b1e72903f5" else "51fdd02b67508306ad4484ff574a0b62",
|
||||
"variables" to JSONObject(variables).toString()
|
||||
)
|
||||
return repository.fetch(queryMap)
|
||||
return service.fetch(queryMap)
|
||||
}
|
||||
|
||||
// TODO convert string response to a response class
|
||||
suspend fun fetchUser(
|
||||
username: String,
|
||||
): User {
|
||||
val response = repository.getUser(username)
|
||||
val response = service.getUser(username)
|
||||
val body = JSONObject(response)
|
||||
val userJson = body.getJSONObject("graphql").getJSONObject(Constants.EXTRAS_USER)
|
||||
val isPrivate = userJson.getBoolean("is_private")
|
||||
@ -220,7 +220,7 @@ object GraphQLService {
|
||||
suspend fun fetchPost(
|
||||
shortcode: String,
|
||||
): Media {
|
||||
val response = repository.getPost(shortcode)
|
||||
val response = service.getPost(shortcode)
|
||||
val body = JSONObject(response)
|
||||
val media = body.getJSONObject("graphql").getJSONObject("shortcode_media")
|
||||
return ResponseBodyUtils.parseGraphQLItem(media, null)
|
||||
@ -230,7 +230,7 @@ object GraphQLService {
|
||||
suspend fun fetchTag(
|
||||
tag: String,
|
||||
): Hashtag {
|
||||
val response = repository.getTag(tag)
|
||||
val response = service.getTag(tag)
|
||||
val body = JSONObject(response)
|
||||
.getJSONObject("graphql")
|
||||
.getJSONObject(Constants.EXTRAS_HASHTAG)
|
||||
@ -247,7 +247,7 @@ object GraphQLService {
|
||||
suspend fun fetchLocation(
|
||||
locationId: Long,
|
||||
): Location {
|
||||
val response = repository.getLocation(locationId)
|
||||
val response = service.getLocation(locationId)
|
||||
val body = JSONObject(response)
|
||||
.getJSONObject("graphql")
|
||||
.getJSONObject(Constants.EXTRAS_LOCATION)
|
Loading…
Reference in New Issue
Block a user