Improved search responsiveness

This commit is contained in:
Eduard Urbach 2018-03-16 19:13:23 +01:00
parent 2aec328e9c
commit 20981234f6
2 changed files with 67 additions and 52 deletions

View File

@ -7,32 +7,55 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
Icon("tv")
span Anime
.profile-watching-list.anime-search
if len(animes) == 0
p.no-search-results.mountable No anime found.
else
each anime in animes
a.profile-watching-list-item.mountable.ajax(href=anime.Link(), title=anime.Title.Canonical, data-mountable-type="anime")
img.anime-cover-image.anime-search-result.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.Canonical)
AnimeSearchResults(animes)
.widget
h3.widget-title
Icon("user")
span Characters
.character-search
if len(characters) == 0
p.no-search-results.mountable No characters found.
else
each character in characters
.mountable(data-mountable-type="character")
CharacterSmall(character)
CharacterSearchResults(characters)
.widget
h3.widget-title
Icon("comment")
span Forum
ForumSearchResults(posts, threads)
.widget
h3.widget-title
Icon("music")
span Soundtracks
SoundTrackSearchResults(tracks)
.widget
h3.widget-title
Icon("user")
span Users
UserSearchResults(users)
component AnimeSearchResults(animes []*arn.Anime)
if len(animes) == 0
p.no-search-results.mountable No anime found.
else
.profile-watching-list.anime-search
each anime in animes
a.profile-watching-list-item.mountable.ajax(href=anime.Link(), title=anime.Title.Canonical, data-mountable-type="anime")
img.anime-cover-image.anime-search-result.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.Canonical)
component CharacterSearchResults(characters []*arn.Character)
if len(characters) == 0
p.no-search-results.mountable No characters found.
else
.character-search
each character in characters
.mountable(data-mountable-type="character")
CharacterSmall(character)
component ForumSearchResults(posts []*arn.Post, threads []*arn.Thread)
if len(posts) == 0 && len(threads) == 0
p.no-search-results.mountable No posts found.
else
@ -53,11 +76,7 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
.forum-search-result-author= post.Author().Nick
.forum-search-result-sample= post.Text
.widget
h3.widget-title
Icon("music")
span Soundtracks
component SoundTrackSearchResults(tracks []*arn.SoundTrack)
if len(tracks) == 0
p.no-search-results.mountable No soundtracks found.
else
@ -66,17 +85,12 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
li.mountable(data-mountable-type="track")
a.ajax(href=track.Link())= track.Title
.widget
h3.widget-title
Icon("user")
span Users
.user-avatars.user-search
component UserSearchResults(users []*arn.User)
if len(users) == 0
p.no-search-results.mountable No users found.
else
.user-avatars.user-search
each user in users
.mountable(data-mountable-type="user")
Avatar(user)
//- a.ajax(href=user.Link())= user.Nick

View File

@ -671,11 +671,12 @@ export class AnimeNotifier {
}
let path = "/_" + url
let request = this.app.get(path)
let request = fetch(path, {
credentials: "same-origin"
})
.then(response => response.text())
// let request = fetch(path, {
// credentials: "same-origin"
// })
// .then(response => response.text())
history.pushState(url, null, url)
this.app.currentPath = url