Skip to content

Commit

Permalink
Remove Upvoting functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
florina-muntenescu committed Jul 3, 2019
1 parent 3393bb7 commit 885a002
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 755 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ import io.plaidapp.designernews.data.comments.CommentsRemoteDataSource
import io.plaidapp.designernews.data.comments.CommentsRepository
import io.plaidapp.designernews.data.users.UserRemoteDataSource
import io.plaidapp.designernews.data.users.UserRepository
import io.plaidapp.designernews.data.votes.VotesRemoteDataSource
import io.plaidapp.designernews.data.votes.VotesRepository
import io.plaidapp.designernews.domain.GetCommentsWithRepliesAndUsersUseCase
import io.plaidapp.designernews.domain.GetStoryUseCase
import io.plaidapp.designernews.domain.PostReplyUseCase
import io.plaidapp.designernews.domain.PostStoryCommentUseCase
import io.plaidapp.designernews.domain.UpvoteCommentUseCase
import io.plaidapp.designernews.domain.UpvoteStoryUseCase
import io.plaidapp.designernews.ui.DesignerNewsViewModelFactory
import io.plaidapp.designernews.ui.login.LoginViewModel
import io.plaidapp.designernews.ui.story.StoryActivity
Expand Down Expand Up @@ -64,8 +60,6 @@ class StoryModule(private val storyId: Long, private val activity: StoryActivity
postStoryCommentUseCase: PostStoryCommentUseCase,
postReplyUseCase: PostReplyUseCase,
commentsWithRepliesAndUsersUseCase: GetCommentsWithRepliesAndUsersUseCase,
upvoteStoryUseCase: UpvoteStoryUseCase,
upvoteCommentUseCase: UpvoteCommentUseCase,
coroutinesDispatcherProvider: CoroutinesDispatcherProvider
): StoryViewModelFactory =
StoryViewModelFactory(
Expand All @@ -74,8 +68,6 @@ class StoryModule(private val storyId: Long, private val activity: StoryActivity
postStoryCommentUseCase,
postReplyUseCase,
commentsWithRepliesAndUsersUseCase,
upvoteStoryUseCase,
upvoteCommentUseCase,
coroutinesDispatcherProvider
)

Expand All @@ -89,11 +81,6 @@ class StoryModule(private val storyId: Long, private val activity: StoryActivity
fun provideCommentsRemoteDataSource(service: DesignerNewsService): CommentsRemoteDataSource =
CommentsRemoteDataSource(service)

@Provides
@FeatureScope
fun provideVotesRepository(remoteDataSource: VotesRemoteDataSource): VotesRepository =
VotesRepository(remoteDataSource)

@Provides
@FeatureScope
fun provideCommentsRepository(dataSource: CommentsRemoteDataSource): CommentsRepository =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package io.plaidapp.designernews.data.api

import io.plaidapp.core.data.api.EnvelopePayload
import io.plaidapp.core.designernews.data.users.model.User
import io.plaidapp.designernews.data.votes.model.UpvoteCommentRequest
import io.plaidapp.designernews.data.votes.model.UpvoteStoryRequest
import io.plaidapp.designernews.data.comments.model.CommentResponse
import io.plaidapp.designernews.data.comments.model.NewCommentRequest
import io.plaidapp.designernews.data.comments.model.PostCommentResponse
Expand All @@ -42,10 +40,6 @@ interface DesignerNewsService {
@GET("api/v2/users/{ids}")
suspend fun getUsers(@Path("ids") userids: String): Response<List<User>>

@Headers("Content-Type: application/vnd.api+json")
@POST("api/v2/upvotes")
suspend fun upvoteStory(@Body request: UpvoteStoryRequest): Response<Unit>

@EnvelopePayload("comments")
@GET("api/v2/comments/{ids}")
suspend fun getComments(@Path("ids") commentIds: String): Response<List<CommentResponse>>
Expand All @@ -54,10 +48,6 @@ interface DesignerNewsService {
@POST("api/v2/comments")
suspend fun comment(@Body comment: NewCommentRequest): Response<PostCommentResponse>

@Headers("Content-Type: application/vnd.api+json")
@POST("api/v2/comment_upvotes")
suspend fun upvoteComment(@Body request: UpvoteCommentRequest): Response<Unit>

companion object {
const val ENDPOINT = "https://www.designernews.co/"
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import io.plaidapp.designernews.domain.GetCommentsWithRepliesAndUsersUseCase
import io.plaidapp.designernews.domain.GetStoryUseCase
import io.plaidapp.designernews.domain.PostReplyUseCase
import io.plaidapp.designernews.domain.PostStoryCommentUseCase
import io.plaidapp.designernews.domain.UpvoteCommentUseCase
import io.plaidapp.designernews.domain.UpvoteStoryUseCase
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

Expand All @@ -44,8 +42,6 @@ class StoryViewModel(
private var postStoryComment: PostStoryCommentUseCase,
private var postReply: PostReplyUseCase,
private val getCommentsWithRepliesAndUsers: GetCommentsWithRepliesAndUsersUseCase,
private val upvoteStory: UpvoteStoryUseCase,
private val upvoteComment: UpvoteCommentUseCase,
private val dispatcherProvider: CoroutinesDispatcherProvider
) : ViewModel() {

Expand All @@ -66,19 +62,6 @@ class StoryViewModel(
}.exhaustive
}

fun storyUpvoteRequested(storyId: Long, onResult: (result: Result<Unit>) -> Unit) =
viewModelScope.launch(dispatcherProvider.computation) {
val result = upvoteStory(storyId)
withContext(dispatcherProvider.main) { onResult(result) }
}

fun commentUpvoteRequested(commentId: Long, onResult: (result: Result<Unit>) -> Unit) =
viewModelScope.launch(dispatcherProvider.computation) {

val result = upvoteComment(commentId)
withContext(dispatcherProvider.main) { onResult(result) }
}

fun commentReplyRequested(
text: CharSequence,
commentId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import io.plaidapp.designernews.domain.GetCommentsWithRepliesAndUsersUseCase
import io.plaidapp.designernews.domain.GetStoryUseCase
import io.plaidapp.designernews.domain.PostReplyUseCase
import io.plaidapp.designernews.domain.PostStoryCommentUseCase
import io.plaidapp.designernews.domain.UpvoteCommentUseCase
import io.plaidapp.designernews.domain.UpvoteStoryUseCase

/**
* Factory for creating [StoryViewModel] with args.
Expand All @@ -35,8 +33,6 @@ class StoryViewModelFactory(
private var postStoryComment: PostStoryCommentUseCase,
private var postReply: PostReplyUseCase,
private val getCommentsWithRepliesAndUsersUseCase: GetCommentsWithRepliesAndUsersUseCase,
private val upvoteStoryUseCase: UpvoteStoryUseCase,
private val upvoteCommentUseCase: UpvoteCommentUseCase,
private val dispatcherProvider: CoroutinesDispatcherProvider
) : ViewModelProvider.Factory {

Expand All @@ -51,8 +47,6 @@ class StoryViewModelFactory(
postStoryComment,
postReply,
getCommentsWithRepliesAndUsersUseCase,
upvoteStoryUseCase,
upvoteCommentUseCase,
dispatcherProvider
) as T
}
Expand Down
Loading

0 comments on commit 885a002

Please sign in to comment.