Added difference ignore button

This commit is contained in:
Eduard Urbach 2018-03-09 14:48:00 +01:00
parent 1e63498fa3
commit cb9e277718
10 changed files with 84 additions and 18 deletions

View File

@ -12,7 +12,7 @@ import (
"github.com/animenotifier/notify.moe/utils"
)
const maxCompareMALEntries = 20
const maxCompareMALEntries = 10
// CompareMAL ...
func CompareMAL(ctx *aero.Context) string {
@ -66,8 +66,9 @@ func CompareMAL(ctx *aero.Context) string {
if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "CanonicalTitle", hash) {
differences = append(differences, &animediff.CanonicalTitle{
TitleA: anime.Title.Canonical,
TitleB: malAnime.Title,
TitleA: anime.Title.Canonical,
TitleB: malAnime.Title,
NumericHash: hash,
})
}
}
@ -78,8 +79,9 @@ func CompareMAL(ctx *aero.Context) string {
if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "JapaneseTitle", hash) {
differences = append(differences, &animediff.JapaneseTitle{
TitleA: anime.Title.Japanese,
TitleB: malAnime.JapaneseTitle,
TitleA: anime.Title.Japanese,
TitleB: malAnime.JapaneseTitle,
NumericHash: hash,
})
}
}
@ -90,8 +92,9 @@ func CompareMAL(ctx *aero.Context) string {
if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "Synopsis", hash) {
differences = append(differences, &animediff.Synopsis{
SynopsisA: anime.Summary,
SynopsisB: malAnime.Synopsis,
SynopsisA: anime.Summary,
SynopsisB: malAnime.Synopsis,
NumericHash: hash,
})
}
}
@ -103,8 +106,9 @@ func CompareMAL(ctx *aero.Context) string {
if hashA != hashB {
if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "Genres", hashB) {
differences = append(differences, &animediff.Genres{
GenresA: anime.Genres,
GenresB: malAnime.Genres,
GenresA: anime.Genres,
GenresB: malAnime.Genres,
NumericHash: hashB,
})
}
}

View File

@ -23,8 +23,12 @@ component CompareMAL(comparisons []*utils.MALComparison, url string, user *arn.U
.data-comparison-differences
each difference in comparison.Differences
.data-comparison-difference
.data-comparison-difference-title= difference.Explanation()
.data-comparison-difference-title
span= difference.Explanation()
.data-comparison-difference-details
.data-comparison-difference-detail= difference.DetailsA()
.data-comparison-difference-detail= difference.DetailsB()
button.data-comparison-difference-ignore.action(data-action="newAnimeDiffIgnore", data-trigger="click", data-id=arn.CreateDifferenceID(comparison.Anime.ID, "mal", comparison.MALAnime.ID, difference.Type()), data-hash=difference.Hash())
RawIcon("trash")

View File

@ -36,6 +36,7 @@
.data-comparison-difference
vertical
ui-element
position relative
padding 0.5rem 0.75rem
margin-bottom 0.5rem
@ -48,3 +49,14 @@
.data-comparison-difference-detail
flex 1
padding 0.5rem 0.75rem
.data-comparison-difference-ignore
position absolute
top 0.5rem
right 0.5rem
width 30px
height 30px
padding 0
display flex
justify-content center
align-items center

View File

@ -1,5 +1,6 @@
export * from "./Actions/AnimeList"
export * from "./Actions/Diff"
export * from "./Actions/Editor"
export * from "./Actions/Explore"
export * from "./Actions/FollowUser"
export * from "./Actions/Forum"

20
scripts/Actions/Editor.ts Normal file
View File

@ -0,0 +1,20 @@
import { AnimeNotifier } from "../AnimeNotifier"
// newAnimeDiffIgnore
export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement) {
if(!confirm("Are you sure you want to permanently ignore this difference?")) {
return
}
let id = button.dataset.id
let hash = button.dataset.hash
arn.post(`/api/new/ignoreanimedifference`, {
id,
hash
})
.then(() => {
arn.reloadContent()
})
.catch(err => arn.statusMessage.showError(err))
}

View File

@ -2,8 +2,9 @@ package animediff
// CanonicalTitle describes differing titles.
type CanonicalTitle struct {
TitleA string
TitleB string
TitleA string
TitleB string
NumericHash uint64
}
// Type returns the diff type.
@ -25,3 +26,8 @@ func (diff *CanonicalTitle) DetailsA() string {
func (diff *CanonicalTitle) DetailsB() string {
return diff.TitleB
}
// Hash returns the hash for the suggested value (from anime B).
func (diff *CanonicalTitle) Hash() uint64 {
return diff.NumericHash
}

View File

@ -4,8 +4,9 @@ import "strings"
// Genres describes differing genres.
type Genres struct {
GenresA []string
GenresB []string
GenresA []string
GenresB []string
NumericHash uint64
}
// Type returns the diff type.
@ -27,3 +28,8 @@ func (diff *Genres) DetailsA() string {
func (diff *Genres) DetailsB() string {
return strings.Join(diff.GenresB, ", ")
}
// Hash returns the hash for the suggested value (from anime B).
func (diff *Genres) Hash() uint64 {
return diff.NumericHash
}

View File

@ -6,4 +6,5 @@ type Difference interface {
Explanation() string
DetailsA() string
DetailsB() string
Hash() uint64
}

View File

@ -2,8 +2,9 @@ package animediff
// JapaneseTitle describes differing Japanese titles.
type JapaneseTitle struct {
TitleA string
TitleB string
TitleA string
TitleB string
NumericHash uint64
}
// Type returns the diff type.
@ -25,3 +26,8 @@ func (diff *JapaneseTitle) DetailsA() string {
func (diff *JapaneseTitle) DetailsB() string {
return diff.TitleB
}
// Hash returns the hash for the suggested value (from anime B).
func (diff *JapaneseTitle) Hash() uint64 {
return diff.NumericHash
}

View File

@ -2,8 +2,9 @@ package animediff
// Synopsis describes differing synopsis.
type Synopsis struct {
SynopsisA string
SynopsisB string
SynopsisA string
SynopsisB string
NumericHash uint64
}
// Type returns the diff type.
@ -25,3 +26,8 @@ func (diff *Synopsis) DetailsA() string {
func (diff *Synopsis) DetailsB() string {
return diff.SynopsisB
}
// Hash returns the hash for the suggested value (from anime B).
func (diff *Synopsis) Hash() uint64 {
return diff.NumericHash
}