feat: delete item from context menu (#251)
* feat: delete item from context menu * fix: follow the naming convention
This commit is contained in:
parent
813b64980d
commit
8177dfdcef
4 changed files with 81 additions and 19 deletions
|
@ -254,20 +254,28 @@ class MediaListDialogFragment : BottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
binding.mediaListDelete.setOnClickListener {
|
||||
val id = media!!.userListId
|
||||
if (id != null) {
|
||||
scope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
Anilist.mutation.deleteList(id)
|
||||
var id = media!!.userListId
|
||||
scope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
if (id != null) {
|
||||
Anilist.mutation.deleteList(id!!)
|
||||
MAL.query.deleteList(media?.anime != null, media?.idMAL)
|
||||
} else {
|
||||
val profile = Anilist.query.userMediaDetails(media!!)
|
||||
profile.userListId?.let { listId ->
|
||||
id = listId
|
||||
Anilist.mutation.deleteList(listId)
|
||||
MAL.query.deleteList(media?.anime != null, media?.idMAL)
|
||||
}
|
||||
}
|
||||
Refresh.all()
|
||||
snackString(getString(R.string.deleted_from_list))
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
if (id != null) {
|
||||
Refresh.all()
|
||||
snackString(getString(R.string.deleted_from_list))
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
snackString(getString(R.string.no_list_id))
|
||||
Refresh.all()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,12 +59,12 @@ class MediaListDialogSmallFragment : BottomSheetDialogFragment() {
|
|||
binding.mediaListContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin += navBarHeight }
|
||||
val scope = viewLifecycleOwner.lifecycleScope
|
||||
binding.mediaListDelete.setOnClickListener {
|
||||
val id = media.userListId
|
||||
if (id != null) {
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
var id = media.userListId
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
if (id != null) {
|
||||
try {
|
||||
Anilist.mutation.deleteList(id)
|
||||
Anilist.mutation.deleteList(id!!)
|
||||
MAL.query.deleteList(media.anime != null, media.idMAL)
|
||||
} catch (e: Exception) {
|
||||
withContext(Dispatchers.Main) {
|
||||
|
@ -72,16 +72,24 @@ class MediaListDialogSmallFragment : BottomSheetDialogFragment() {
|
|||
}
|
||||
return@withContext
|
||||
}
|
||||
} else {
|
||||
val profile = Anilist.query.userMediaDetails(media)
|
||||
profile.userListId?.let { listId ->
|
||||
id = listId
|
||||
Anilist.mutation.deleteList(listId)
|
||||
MAL.query.deleteList(media.anime != null, media.idMAL)
|
||||
}
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
if (id != null) {
|
||||
Refresh.all()
|
||||
snackString(getString(R.string.deleted_from_list))
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
snackString(getString(R.string.no_list_id))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
snackString(getString(R.string.no_list_id))
|
||||
Refresh.all()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue