1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00

Interchange StoriesService and StoriesRepository names.

This commit is contained in:
Ammar Githam 2021-06-12 08:37:22 +09:00
parent 8bb0fba4cb
commit 1191b416ce
8 changed files with 44 additions and 44 deletions

View File

@ -69,7 +69,7 @@ import awais.instagrabber.utils.TextUtils;
import awais.instagrabber.utils.Utils; import awais.instagrabber.utils.Utils;
import awais.instagrabber.webservices.GraphQLService; import awais.instagrabber.webservices.GraphQLService;
import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.ServiceCallback;
import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.StoriesRepository;
import awais.instagrabber.webservices.TagsService; import awais.instagrabber.webservices.TagsService;
import kotlinx.coroutines.Dispatchers; import kotlinx.coroutines.Dispatchers;
@ -93,7 +93,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
private String hashtag; private String hashtag;
private Hashtag hashtagModel = null; private Hashtag hashtagModel = null;
private ActionMode actionMode; private ActionMode actionMode;
private StoriesService storiesService; private StoriesRepository storiesRepository;
private boolean isLoggedIn; private boolean isLoggedIn;
private TagsService tagsService; private TagsService tagsService;
private GraphQLService graphQLService; private GraphQLService graphQLService;
@ -298,7 +298,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
final String cookie = settingsHelper.getString(Constants.COOKIE); final String cookie = settingsHelper.getString(Constants.COOKIE);
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0; isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0;
tagsService = isLoggedIn ? TagsService.getInstance() : null; tagsService = isLoggedIn ? TagsService.getInstance() : null;
storiesService = isLoggedIn ? StoriesService.INSTANCE : null; storiesRepository = isLoggedIn ? StoriesRepository.INSTANCE : null;
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE; graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@ -585,7 +585,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
private void fetchStories() { private void fetchStories() {
if (!isLoggedIn) return; if (!isLoggedIn) return;
storiesFetching = true; storiesFetching = true;
storiesService.getUserStory( storiesRepository.getUserStory(
StoryViewerOptions.forHashtag(hashtagModel.getName()), StoryViewerOptions.forHashtag(hashtagModel.getName()),
CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {

View File

@ -66,7 +66,7 @@ import awais.instagrabber.utils.Utils;
import awais.instagrabber.webservices.GraphQLService; import awais.instagrabber.webservices.GraphQLService;
import awais.instagrabber.webservices.LocationService; import awais.instagrabber.webservices.LocationService;
import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.ServiceCallback;
import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.StoriesRepository;
import kotlinx.coroutines.Dispatchers; import kotlinx.coroutines.Dispatchers;
import static androidx.core.content.PermissionChecker.checkSelfPermission; import static androidx.core.content.PermissionChecker.checkSelfPermission;
@ -87,7 +87,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
private long locationId; private long locationId;
private Location locationModel; private Location locationModel;
private ActionMode actionMode; private ActionMode actionMode;
private StoriesService storiesService; private StoriesRepository storiesRepository;
private GraphQLService graphQLService; private GraphQLService graphQLService;
private LocationService locationService; private LocationService locationService;
private boolean isLoggedIn; private boolean isLoggedIn;
@ -291,7 +291,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
final String cookie = settingsHelper.getString(Constants.COOKIE); final String cookie = settingsHelper.getString(Constants.COOKIE);
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0; isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0;
locationService = isLoggedIn ? LocationService.getInstance() : null; locationService = isLoggedIn ? LocationService.getInstance() : null;
storiesService = StoriesService.INSTANCE; storiesRepository = StoriesRepository.INSTANCE;
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE; graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@ -589,7 +589,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
private void fetchStories() { private void fetchStories() {
if (isLoggedIn) { if (isLoggedIn) {
storiesFetching = true; storiesFetching = true;
storiesService.getUserStory( storiesRepository.getUserStory(
StoryViewerOptions.forLocation(locationId, locationModel.getName()), StoryViewerOptions.forLocation(locationId, locationModel.getName()),
CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {

View File

@ -47,8 +47,8 @@ import awais.instagrabber.utils.TextUtils;
import awais.instagrabber.viewmodels.ArchivesViewModel; import awais.instagrabber.viewmodels.ArchivesViewModel;
import awais.instagrabber.viewmodels.FeedStoriesViewModel; import awais.instagrabber.viewmodels.FeedStoriesViewModel;
import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.ServiceCallback;
import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.StoriesRepository;
import awais.instagrabber.webservices.StoriesService.ArchiveFetchResponse; import awais.instagrabber.webservices.StoriesRepository.ArchiveFetchResponse;
import kotlinx.coroutines.Dispatchers; import kotlinx.coroutines.Dispatchers;
public final class StoryListViewerFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { public final class StoryListViewerFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
@ -61,7 +61,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
private boolean firstRefresh = true; private boolean firstRefresh = true;
private FeedStoriesViewModel feedStoriesViewModel; private FeedStoriesViewModel feedStoriesViewModel;
private ArchivesViewModel archivesViewModel; private ArchivesViewModel archivesViewModel;
private StoriesService storiesService; private StoriesRepository storiesRepository;
private Context context; private Context context;
private String type; private String type;
private String endCursor = null; private String endCursor = null;
@ -136,7 +136,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
context = getContext(); context = getContext();
if (context == null) return; if (context == null) return;
setHasOptionsMenu(true); setHasOptionsMenu(true);
storiesService = StoriesService.INSTANCE; storiesRepository = StoriesRepository.INSTANCE;
} }
@NonNull @NonNull
@ -242,7 +242,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
} }
firstRefresh = false; firstRefresh = false;
} else if (type.equals("feed")) { } else if (type.equals("feed")) {
storiesService.getFeedStories( storiesRepository.getFeedStories(
CoroutineUtilsKt.getContinuation((feedStoryModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((feedStoryModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {
Log.e(TAG, "failed", throwable); Log.e(TAG, "failed", throwable);
@ -257,7 +257,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
}), Dispatchers.getIO()) }), Dispatchers.getIO())
); );
} else if (type.equals("archive")) { } else if (type.equals("archive")) {
storiesService.fetchArchive( storiesRepository.fetchArchive(
endCursor, endCursor,
CoroutineUtilsKt.getContinuation((archiveFetchResponse, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((archiveFetchResponse, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {

View File

@ -101,7 +101,7 @@ import awais.instagrabber.viewmodels.StoriesViewModel;
import awais.instagrabber.webservices.DirectMessagesService; import awais.instagrabber.webservices.DirectMessagesService;
import awais.instagrabber.webservices.MediaService; import awais.instagrabber.webservices.MediaService;
import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.ServiceCallback;
import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.StoriesRepository;
import kotlinx.coroutines.Dispatchers; import kotlinx.coroutines.Dispatchers;
import static awais.instagrabber.customviews.helpers.SwipeGestureListener.SWIPE_THRESHOLD; import static awais.instagrabber.customviews.helpers.SwipeGestureListener.SWIPE_THRESHOLD;
@ -122,7 +122,7 @@ public class StoryViewerFragment extends Fragment {
private StoriesAdapter storiesAdapter; private StoriesAdapter storiesAdapter;
private SwipeEvent swipeEvent; private SwipeEvent swipeEvent;
private GestureDetectorCompat gestureDetector; private GestureDetectorCompat gestureDetector;
private StoriesService storiesService; private StoriesRepository storiesRepository;
private MediaService mediaService; private MediaService mediaService;
private StoryModel currentStory; private StoryModel currentStory;
private int slidePos; private int slidePos;
@ -162,7 +162,7 @@ public class StoryViewerFragment extends Fragment {
userId = CookieUtils.getUserIdFromCookie(cookie); userId = CookieUtils.getUserIdFromCookie(cookie);
deviceId = settingsHelper.getString(Constants.DEVICE_UUID); deviceId = settingsHelper.getString(Constants.DEVICE_UUID);
fragmentActivity = (AppCompatActivity) requireActivity(); fragmentActivity = (AppCompatActivity) requireActivity();
storiesService = StoriesService.INSTANCE; storiesRepository = StoriesRepository.INSTANCE;
mediaService = MediaService.INSTANCE; mediaService = MediaService.INSTANCE;
directMessagesService = DirectMessagesService.INSTANCE; directMessagesService = DirectMessagesService.INSTANCE;
setHasOptionsMenu(true); setHasOptionsMenu(true);
@ -521,7 +521,7 @@ public class StoryViewerFragment extends Fragment {
poll.getRightChoice() + " (" + poll.getRightCount() + ")" poll.getRightChoice() + " (" + poll.getRightCount() + ")"
}), (d, w) -> { }), (d, w) -> {
sticking = true; sticking = true;
storiesService.respondToPoll( storiesRepository.respondToPoll(
csrfToken, csrfToken,
userId, userId,
deviceId, deviceId,
@ -560,7 +560,7 @@ public class StoryViewerFragment extends Fragment {
.setView(input) .setView(input)
.setPositiveButton(R.string.confirm, (d, w) -> { .setPositiveButton(R.string.confirm, (d, w) -> {
sticking = true; sticking = true;
storiesService.respondToQuestion( storiesRepository.respondToQuestion(
csrfToken, csrfToken,
userId, userId,
deviceId, deviceId,
@ -618,7 +618,7 @@ public class StoryViewerFragment extends Fragment {
.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, choices), (d, w) -> { .setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, choices), (d, w) -> {
if (quiz.getMyChoice() == -1) { if (quiz.getMyChoice() == -1) {
sticking = true; sticking = true;
storiesService.respondToQuiz( storiesRepository.respondToQuiz(
csrfToken, csrfToken,
userId, userId,
deviceId, deviceId,
@ -689,7 +689,7 @@ public class StoryViewerFragment extends Fragment {
.setView(sliderView) .setView(sliderView)
.setPositiveButton(R.string.confirm, (d, w) -> { .setPositiveButton(R.string.confirm, (d, w) -> {
sticking = true; sticking = true;
storiesService.respondToSlider( storiesRepository.respondToSlider(
csrfToken, csrfToken,
userId, userId,
deviceId, deviceId,
@ -805,7 +805,7 @@ public class StoryViewerFragment extends Fragment {
setTitle(type); setTitle(type);
storiesViewModel.getList().setValue(Collections.emptyList()); storiesViewModel.getList().setValue(Collections.emptyList());
if (type == Type.STORY) { if (type == Type.STORY) {
storiesService.fetch( storiesRepository.fetch(
options.getId(), options.getId(),
CoroutineUtilsKt.getContinuation((storyModel, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((storyModel, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {
@ -858,7 +858,7 @@ public class StoryViewerFragment extends Fragment {
storyCallback.onSuccess(Collections.singletonList(live)); storyCallback.onSuccess(Collections.singletonList(live));
return; return;
} }
storiesService.getUserStory( storiesRepository.getUserStory(
fetchOptions, fetchOptions,
CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {
@ -972,7 +972,7 @@ public class StoryViewerFragment extends Fragment {
} }
if (settingsHelper.getBoolean(MARK_AS_SEEN)) if (settingsHelper.getBoolean(MARK_AS_SEEN))
storiesService.seen( storiesRepository.seen(
csrfToken, csrfToken,
userId, userId,
deviceId, deviceId,

View File

@ -54,7 +54,7 @@ import awais.instagrabber.utils.CoroutineUtilsKt;
import awais.instagrabber.utils.DownloadUtils; import awais.instagrabber.utils.DownloadUtils;
import awais.instagrabber.utils.Utils; import awais.instagrabber.utils.Utils;
import awais.instagrabber.viewmodels.FeedStoriesViewModel; import awais.instagrabber.viewmodels.FeedStoriesViewModel;
import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.StoriesRepository;
import kotlinx.coroutines.Dispatchers; import kotlinx.coroutines.Dispatchers;
import static androidx.core.content.PermissionChecker.checkSelfPermission; import static androidx.core.content.PermissionChecker.checkSelfPermission;
@ -68,7 +68,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
private MainActivity fragmentActivity; private MainActivity fragmentActivity;
private MotionLayout root; private MotionLayout root;
private FragmentFeedBinding binding; private FragmentFeedBinding binding;
private StoriesService storiesService; private StoriesRepository storiesRepository;
private boolean shouldRefresh = true; private boolean shouldRefresh = true;
private final boolean isRotate = false; private final boolean isRotate = false;
private FeedStoriesViewModel feedStoriesViewModel; private FeedStoriesViewModel feedStoriesViewModel;
@ -276,7 +276,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
public void onCreate(@Nullable final Bundle savedInstanceState) { public void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
fragmentActivity = (MainActivity) requireActivity(); fragmentActivity = (MainActivity) requireActivity();
storiesService = StoriesService.INSTANCE; storiesRepository = StoriesRepository.INSTANCE;
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@ -430,7 +430,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
// final String cookie = settingsHelper.getString(Constants.COOKIE); // final String cookie = settingsHelper.getString(Constants.COOKIE);
storiesFetching = true; storiesFetching = true;
updateSwipeRefreshState(); updateSwipeRefreshState();
storiesService.getFeedStories( storiesRepository.getFeedStories(
CoroutineUtilsKt.getContinuation((feedStoryModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((feedStoryModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {
Log.e(TAG, "failed", throwable); Log.e(TAG, "failed", throwable);

View File

@ -96,7 +96,7 @@ import awais.instagrabber.webservices.FriendshipRepository;
import awais.instagrabber.webservices.GraphQLService; import awais.instagrabber.webservices.GraphQLService;
import awais.instagrabber.webservices.MediaService; import awais.instagrabber.webservices.MediaService;
import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.ServiceCallback;
import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.StoriesRepository;
import awais.instagrabber.webservices.UserRepository; import awais.instagrabber.webservices.UserRepository;
import kotlinx.coroutines.Dispatchers; import kotlinx.coroutines.Dispatchers;
@ -119,7 +119,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
private ActionMode actionMode; private ActionMode actionMode;
private Handler usernameSettingHandler; private Handler usernameSettingHandler;
private FriendshipRepository friendshipRepository; private FriendshipRepository friendshipRepository;
private StoriesService storiesService; private StoriesRepository storiesRepository;
private MediaService mediaService; private MediaService mediaService;
private UserRepository userRepository; private UserRepository userRepository;
private GraphQLService graphQLService; private GraphQLService graphQLService;
@ -335,7 +335,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
fragmentActivity = (MainActivity) requireActivity(); fragmentActivity = (MainActivity) requireActivity();
friendshipRepository = isLoggedIn ? FriendshipRepository.Companion.getInstance() : null; friendshipRepository = isLoggedIn ? FriendshipRepository.Companion.getInstance() : null;
directMessagesService = isLoggedIn ? DirectMessagesService.INSTANCE : null; directMessagesService = isLoggedIn ? DirectMessagesService.INSTANCE : null;
storiesService = isLoggedIn ? StoriesService.INSTANCE : null; storiesRepository = isLoggedIn ? StoriesRepository.INSTANCE : null;
mediaService = isLoggedIn ? MediaService.INSTANCE : null; mediaService = isLoggedIn ? MediaService.INSTANCE : null;
userRepository = isLoggedIn ? UserRepository.Companion.getInstance() : null; userRepository = isLoggedIn ? UserRepository.Companion.getInstance() : null;
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE; graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
@ -1046,7 +1046,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
private void fetchStoryAndHighlights(final long profileId) { private void fetchStoryAndHighlights(final long profileId) {
storiesService.getUserStory( storiesRepository.getUserStory(
StoryViewerOptions.forUser(profileId, profileModel.getFullName()), StoryViewerOptions.forUser(profileId, profileModel.getFullName()),
CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {
@ -1059,7 +1059,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
}), Dispatchers.getIO()) }), Dispatchers.getIO())
); );
storiesService.fetchHighlights( storiesRepository.fetchHighlights(
profileId, profileId,
CoroutineUtilsKt.getContinuation((highlightModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> { CoroutineUtilsKt.getContinuation((highlightModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) { if (throwable != null) {

View File

@ -3,7 +3,7 @@ package awais.instagrabber.repositories
import awais.instagrabber.repositories.responses.StoryStickerResponse import awais.instagrabber.repositories.responses.StoryStickerResponse
import retrofit2.http.* import retrofit2.http.*
interface StoriesRepository { interface StoriesService {
// this one is the same as MediaRepository.fetch BUT you need to make sure it's a story // this one is the same as MediaRepository.fetch BUT you need to make sure it's a story
@GET("/api/v1/media/{mediaId}/info/") @GET("/api/v1/media/{mediaId}/info/")
suspend fun fetch(@Path("mediaId") mediaId: Long): String suspend fun fetch(@Path("mediaId") mediaId: Long): String

View File

@ -5,7 +5,7 @@ import awais.instagrabber.fragments.settings.PreferenceKeys
import awais.instagrabber.models.FeedStoryModel import awais.instagrabber.models.FeedStoryModel
import awais.instagrabber.models.HighlightModel import awais.instagrabber.models.HighlightModel
import awais.instagrabber.models.StoryModel import awais.instagrabber.models.StoryModel
import awais.instagrabber.repositories.StoriesRepository import awais.instagrabber.repositories.StoriesService
import awais.instagrabber.repositories.requests.StoryViewerOptions import awais.instagrabber.repositories.requests.StoryViewerOptions
import awais.instagrabber.repositories.responses.StoryStickerResponse import awais.instagrabber.repositories.responses.StoryStickerResponse
import awais.instagrabber.repositories.responses.User import awais.instagrabber.repositories.responses.User
@ -19,17 +19,17 @@ import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import java.util.* import java.util.*
object StoriesService { object StoriesRepository {
private val repository: StoriesRepository = retrofit.create(StoriesRepository::class.java) private val service: StoriesService = retrofit.create(StoriesService::class.java)
suspend fun fetch(mediaId: Long): StoryModel { suspend fun fetch(mediaId: Long): StoryModel {
val response = repository.fetch(mediaId) val response = service.fetch(mediaId)
val itemJson = JSONObject(response).getJSONArray("items").getJSONObject(0) val itemJson = JSONObject(response).getJSONArray("items").getJSONObject(0)
return ResponseBodyUtils.parseStoryItem(itemJson, false, null) return ResponseBodyUtils.parseStoryItem(itemJson, false, null)
} }
suspend fun getFeedStories(): List<FeedStoryModel> { suspend fun getFeedStories(): List<FeedStoryModel> {
val response = repository.getFeedStories() val response = service.getFeedStories()
return parseStoriesBody(response) return parseStoriesBody(response)
} }
@ -94,7 +94,7 @@ object StoriesService {
} }
suspend fun fetchHighlights(profileId: Long): List<HighlightModel> { suspend fun fetchHighlights(profileId: Long): List<HighlightModel> {
val response = repository.fetchHighlights(profileId) val response = service.fetchHighlights(profileId)
val highlightsReel = JSONObject(response).getJSONArray("tray") val highlightsReel = JSONObject(response).getJSONArray("tray")
val length = highlightsReel.length() val length = highlightsReel.length()
val highlightModels: MutableList<HighlightModel> = ArrayList() val highlightModels: MutableList<HighlightModel> = ArrayList()
@ -122,7 +122,7 @@ object StoriesService {
if (!isEmpty(maxId)) { if (!isEmpty(maxId)) {
form["max_id"] = maxId // NOT TESTED form["max_id"] = maxId // NOT TESTED
} }
val response = repository.fetchArchive(form) val response = service.fetchArchive(form)
val data = JSONObject(response) val data = JSONObject(response)
val highlightsReel = data.getJSONArray("items") val highlightsReel = data.getJSONArray("items")
val length = highlightsReel.length() val length = highlightsReel.length()
@ -142,7 +142,7 @@ object StoriesService {
suspend fun getUserStory(options: StoryViewerOptions): List<StoryModel> { suspend fun getUserStory(options: StoryViewerOptions): List<StoryModel> {
val url = buildUrl(options) ?: return emptyList() val url = buildUrl(options) ?: return emptyList()
val response = repository.getUserStory(url) val response = service.getUserStory(url)
val isLocOrHashtag = options.type == StoryViewerOptions.Type.LOCATION || options.type == StoryViewerOptions.Type.HASHTAG val isLocOrHashtag = options.type == StoryViewerOptions.Type.LOCATION || options.type == StoryViewerOptions.Type.HASHTAG
val isHighlight = options.type == StoryViewerOptions.Type.HIGHLIGHT || options.type == StoryViewerOptions.Type.STORY_ARCHIVE val isHighlight = options.type == StoryViewerOptions.Type.HIGHLIGHT || options.type == StoryViewerOptions.Type.STORY_ARCHIVE
var data: JSONObject? = JSONObject(response) var data: JSONObject? = JSONObject(response)
@ -187,7 +187,7 @@ object StoriesService {
arg1 to arg2, arg1 to arg2,
) )
val signedForm = Utils.sign(form) val signedForm = Utils.sign(form)
return repository.respondToSticker(storyId, stickerId, action, signedForm) return service.respondToSticker(storyId, stickerId, action, signedForm)
} }
suspend fun respondToQuestion( suspend fun respondToQuestion(
@ -249,7 +249,7 @@ object StoriesService {
"reel" to "1", "reel" to "1",
"live_vod" to "0", "live_vod" to "0",
) )
return repository.seen(queryMap, signedForm) return service.seen(queryMap, signedForm)
} }
private fun buildUrl(options: StoryViewerOptions): String? { private fun buildUrl(options: StoryViewerOptions): String? {