Skip to content

Commit

Permalink
feat: support remove faverite
Browse files Browse the repository at this point in the history
  • Loading branch information
haowenwu committed Oct 8, 2024
1 parent 99310f2 commit d894552
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions BilibiliLive/Component/Video/VideoDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ class VideoDetailViewController: UIViewController {
guard let favList = try? await WebRequest.requestFavVideosList() else {
return
}
if favButton.isOn {
favButton.title? -= 1
favButton.isOn = false
WebRequest.removeFavorite(aid: aid, mid: favList.map { $0.id })
return
}
let alert = UIAlertController(title: "收藏", message: nil, preferredStyle: .actionSheet)
let aid = aid
for fav in favList {
Expand Down
4 changes: 4 additions & 0 deletions BilibiliLive/Request/WebRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ extension WebRequest {
requestJSON(method: .post, url: "https://api.bilibili.com/x/v3/fav/resource/deal", parameters: ["rid": aid, "type": 2, "add_media_ids": mid])
}

static func removeFavorite(aid: Int, mid: [Int]) {
requestJSON(method: .post, url: "https://api.bilibili.com/x/v3/fav/resource/deal", parameters: ["rid": aid, "type": 2, "del_media_ids": mid.map { "\($0)" }.joined(separator: ",")])
}

static func requestFavoriteStatus(aid: Int, complete: ((Bool) -> Void)?) {
requestJSON(url: "https://api.bilibili.com/x/v2/fav/video/favoured", parameters: ["aid": aid]) {
response in
Expand Down

0 comments on commit d894552

Please # to comment.