Skip to content

Commit

Permalink
Merge branch 'dev-book-title' of https://github.com/primetoxinz/komga
Browse files Browse the repository at this point in the history
…into primetoxinz-dev-book-title
  • Loading branch information
gotson committed Feb 25, 2020
2 parents 3d7e633 + 23c10c2 commit f7390f0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
11 changes: 11 additions & 0 deletions komga-webui/src/functions/meta-utilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import KomgaSeriesService from '@/services/komga-series.service'

export async function getBookTitle (komgaSeries: KomgaSeriesService, book: BookDto): Promise<string> {
return komgaSeries.getOneSeries(book.seriesId).then(series => {
if (book.name.toLowerCase().includes(series.name.toLowerCase())) {
return book.name
} else {
return `${series.name} - ${book.name}`
}
})
}
1 change: 1 addition & 0 deletions komga-webui/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const router = new Router({
})

router.beforeEach((to, from, next) => {
document.title = 'Komga'
if (to.name !== 'startup' && to.name !== 'login' && !lStore.getters.authenticated) next({ name: 'startup' })
else next()
})
Expand Down
6 changes: 6 additions & 0 deletions komga-webui/src/views/BookReader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ import { checkWebpFeature } from '@/functions/check-webp'
import { bookPageThumbnailUrl, bookPageUrl } from '@/functions/urls'
import { ImageFit } from '@/types/common'
import Vue from 'vue'
import { getBookTitle } from '@/functions/meta-utilities'
const cookieFit = 'webreader.fit'
const cookieRtl = 'webreader.rtl'
Expand Down Expand Up @@ -457,6 +458,7 @@ export default Vue.extend({
async setup (bookId: number, page: number) {
this.book = await this.$komgaBooks.getBook(bookId)
this.pages = await this.$komgaBooks.getBookPages(bookId)
this.updateTitle()
if (page >= 1 && page <= this.pagesCount) {
this.goTo(page)
} else {
Expand Down Expand Up @@ -534,6 +536,10 @@ export default Vue.extend({
}
})
},
async updateTitle () {
let title: string = await getBookTitle(this.$komgaSeries, this.book)
document.title = `Komga - ${title}`
},
closeBook () {
this.$router.push({ name: 'browse-book', params: { bookId: this.bookId.toString() } })
},
Expand Down
6 changes: 6 additions & 0 deletions komga-webui/src/views/BrowseBook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import ToolbarSticky from '@/components/ToolbarSticky.vue'
import { getBookFormatFromMediaType } from '@/functions/book-format'
import { bookFileUrl, bookThumbnailUrl } from '@/functions/urls'
import Vue from 'vue'
import { getBookTitle } from '@/functions/meta-utilities'
export default Vue.extend({
name: 'BrowseBook',
Expand All @@ -139,6 +140,7 @@ export default Vue.extend({
},
async created () {
this.book = await this.$komgaBooks.getBook(this.bookId)
this.updateTitle()
},
props: {
bookId: {
Expand Down Expand Up @@ -170,6 +172,10 @@ export default Vue.extend({
methods: {
analyze () {
this.$komgaBooks.analyzeBook(this.book)
},
async updateTitle () {
let title: string = await getBookTitle(this.$komgaSeries, this.book)
document.title = `Komga - ${title}`
}
}
})
Expand Down
4 changes: 3 additions & 1 deletion komga-webui/src/views/BrowseSeries.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default mixins(VisibleElements).extend({
async created () {
this.loadSeries()
},
mounted () {
async mounted () {
// fill books skeletons if an index is provided, so scroll position can be restored
if (this.$route.params.index) {
this.books = Array(Number(this.$route.params.index)).fill(null)
Expand All @@ -178,6 +178,8 @@ export default mixins(VisibleElements).extend({
this.reloadData(Number(this.$route.params.seriesId), this.books.length)
this.setWatches()
await this.loadSeries()
document.title = `Komga - ${this.series.name}`
},
async beforeRouteUpdate (to, from, next) {
if (to.params.seriesId !== from.params.seriesId) {
Expand Down

0 comments on commit f7390f0

Please sign in to comment.