Skip to content

Commit

Permalink
feat: 技術的知識の方が多く含まれており
Browse files Browse the repository at this point in the history
他UseCase層から使用したいというニーズがあるので、Serviceに名称を変更した。
  • Loading branch information
pantasystem committed Jan 14, 2024
1 parent 9a33cfe commit 17776ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import net.pantasystem.milktea.model.note.DeleteAndEditUseCase
import net.pantasystem.milktea.model.note.DeleteNoteUseCase
import net.pantasystem.milktea.model.note.Note
import net.pantasystem.milktea.model.note.NoteRelation
import net.pantasystem.milktea.model.note.RecursiveSearchHasContentNoteUseCase
import net.pantasystem.milktea.model.note.NoteService
import net.pantasystem.milktea.model.note.bookmark.CreateBookmarkUseCase
import net.pantasystem.milktea.model.note.bookmark.DeleteBookmarkUseCase
import net.pantasystem.milktea.model.note.draft.DraftNote
Expand All @@ -39,7 +39,7 @@ import javax.inject.Inject

@HiltViewModel
class NotesViewModel @Inject constructor(
private val recursiveSearchHasContentNoteUseCase: RecursiveSearchHasContentNoteUseCase,
private val noteService: NoteService,
private val toggleReactionUseCase: ToggleReactionUseCase,
private val createFavoriteUseCase: CreateFavoriteUseCase,
private val deleteFavoriteUseCase: DeleteFavoriteUseCase,
Expand Down Expand Up @@ -114,7 +114,7 @@ class NotesViewModel @Inject constructor(
}

private suspend fun recursiveSearchHasContentNote(noteId: Note.Id): Result<Note> =
recursiveSearchHasContentNoteUseCase(noteId)
noteService.findHasContentNote(noteId)

/**
* リアクションを送信する
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import javax.inject.Singleton

@Singleton
class GetShareNoteUrlUseCase @Inject constructor(
private val recursiveSearchHasContentNoteUseCase: RecursiveSearchHasContentNoteUseCase,
private val noteService: NoteService,
private val accountRepository: AccountRepository,
) : UseCase {
suspend operator fun invoke(noteId: Note.Id): Result<String> {
return recursiveSearchHasContentNoteUseCase(noteId).mapCancellableCatching { note ->
return noteService.findHasContentNote(noteId).mapCancellableCatching { note ->
note.getOriginUrl(
accountRepository.get(noteId.accountId).getOrThrow()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import net.pantasystem.milktea.common.mapCancellableCatching
import net.pantasystem.milktea.model.UseCase
import javax.inject.Inject

class RecursiveSearchHasContentNoteUseCase @Inject constructor(
class NoteService @Inject constructor(
private val noteRepository: NoteRepository,
) : UseCase {

suspend operator fun invoke(noteId: Note.Id): Result<Note> {
suspend fun findHasContentNote(noteId: Note.Id): Result<Note> {
return noteRepository.find(noteId).mapCancellableCatching { note ->
if (note.hasContent()) {
note
} else {
invoke(requireNotNull(note.renoteId)).getOrThrow()
findHasContentNote(requireNotNull(note.renoteId)).getOrThrow()
}
}
}
Expand Down

0 comments on commit 17776ca

Please sign in to comment.