From 17776cafc703a4831d381a13353848250d4427d6 Mon Sep 17 00:00:00 2001 From: Yuichiro Kinoshita Date: Sun, 14 Jan 2024 22:30:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=80=E8=A1=93=E7=9A=84=E7=9F=A5?= =?UTF-8?q?=E8=AD=98=E3=81=AE=E6=96=B9=E3=81=8C=E5=A4=9A=E3=81=8F=E5=90=AB?= =?UTF-8?q?=E3=81=BE=E3=82=8C=E3=81=A6=E3=81=8A=E3=82=8A=20=E4=BB=96UseCas?= =?UTF-8?q?e=E5=B1=A4=E3=81=8B=E3=82=89=E4=BD=BF=E7=94=A8=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=81=84=E3=81=A8=E3=81=84=E3=81=86=E3=83=8B=E3=83=BC?= =?UTF-8?q?=E3=82=BA=E3=81=8C=E3=81=82=E3=82=8B=E3=81=AE=E3=81=A7=E3=80=81?= =?UTF-8?q?Service=E3=81=AB=E5=90=8D=E7=A7=B0=E3=82=92=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pantasystem/milktea/note/viewmodel/NotesViewModel.kt | 6 +++--- .../milktea/model/note/GetShareNoteUrlUseCase.kt | 4 ++-- ...cursiveSearchHasContentNoteUseCase.kt => NoteService.kt} | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename modules/model/src/main/java/net/pantasystem/milktea/model/note/{RecursiveSearchHasContentNoteUseCase.kt => NoteService.kt} (68%) diff --git a/modules/features/note/src/main/java/net/pantasystem/milktea/note/viewmodel/NotesViewModel.kt b/modules/features/note/src/main/java/net/pantasystem/milktea/note/viewmodel/NotesViewModel.kt index a87851f416..ae652b90b2 100644 --- a/modules/features/note/src/main/java/net/pantasystem/milktea/note/viewmodel/NotesViewModel.kt +++ b/modules/features/note/src/main/java/net/pantasystem/milktea/note/viewmodel/NotesViewModel.kt @@ -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 @@ -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, @@ -114,7 +114,7 @@ class NotesViewModel @Inject constructor( } private suspend fun recursiveSearchHasContentNote(noteId: Note.Id): Result = - recursiveSearchHasContentNoteUseCase(noteId) + noteService.findHasContentNote(noteId) /** * リアクションを送信する diff --git a/modules/model/src/main/java/net/pantasystem/milktea/model/note/GetShareNoteUrlUseCase.kt b/modules/model/src/main/java/net/pantasystem/milktea/model/note/GetShareNoteUrlUseCase.kt index 1c7c672e19..ed6bf77d49 100644 --- a/modules/model/src/main/java/net/pantasystem/milktea/model/note/GetShareNoteUrlUseCase.kt +++ b/modules/model/src/main/java/net/pantasystem/milktea/model/note/GetShareNoteUrlUseCase.kt @@ -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 { - return recursiveSearchHasContentNoteUseCase(noteId).mapCancellableCatching { note -> + return noteService.findHasContentNote(noteId).mapCancellableCatching { note -> note.getOriginUrl( accountRepository.get(noteId.accountId).getOrThrow() ) diff --git a/modules/model/src/main/java/net/pantasystem/milktea/model/note/RecursiveSearchHasContentNoteUseCase.kt b/modules/model/src/main/java/net/pantasystem/milktea/model/note/NoteService.kt similarity index 68% rename from modules/model/src/main/java/net/pantasystem/milktea/model/note/RecursiveSearchHasContentNoteUseCase.kt rename to modules/model/src/main/java/net/pantasystem/milktea/model/note/NoteService.kt index 9a7f27009b..5a3fc34f63 100644 --- a/modules/model/src/main/java/net/pantasystem/milktea/model/note/RecursiveSearchHasContentNoteUseCase.kt +++ b/modules/model/src/main/java/net/pantasystem/milktea/model/note/NoteService.kt @@ -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 { + suspend fun findHasContentNote(noteId: Note.Id): Result { return noteRepository.find(noteId).mapCancellableCatching { note -> if (note.hasContent()) { note } else { - invoke(requireNotNull(note.renoteId)).getOrThrow() + findHasContentNote(requireNotNull(note.renoteId)).getOrThrow() } } }