2017-11-13 01:23:39 -05:00
< template lang = "html" >
2018-03-30 17:58:56 -04:00
< div class = "ffz--changelog tw-border-t tw-pd-t-1" >
< div class = "tw-align-center" >
2019-11-14 19:52:35 -05:00
< h2 v-if = "addons" >
{ { t ( 'setting.add_ons.changelog.title' , 'Add-Ons Changelog' ) } }
< / h2 >
< h2 v-else >
{ { t ( 'home.changelog' , 'Changelog' ) } }
< / h2 >
2018-03-30 17:58:56 -04:00
< / div >
2017-11-13 01:23:39 -05:00
2019-11-14 19:52:35 -05:00
< div v-if = " ! addons" class="tw-mg-b-1 tw-flex tw-align-items-center" >
2019-10-23 19:30:27 -04:00
< div class = "tw-flex-grow-1" / >
2021-05-17 17:02:23 -04:00
< div class = "ffz-checkbox tw-relative ffz-il-tooltip__container" >
2019-10-23 19:30:27 -04:00
< input
id = "nonversioned"
ref = "nonversioned"
v - model = "nonversioned"
type = "checkbox"
2021-02-11 19:40:12 -05:00
class = "ffz-checkbox__input"
2019-10-23 19:30:27 -04:00
>
2021-02-11 19:40:12 -05:00
< label for = "nonversioned" class = "ffz-checkbox__label" >
2020-02-09 15:10:12 -05:00
< span class = "tw-mg-l-1" >
{ { t ( 'home.changelog.show-nonversioned' , 'Include non-versioned commits.' ) } }
< / span >
2019-10-23 19:30:27 -04:00
< / label >
2021-05-17 17:02:23 -04:00
< div class = "ffz-il-tooltip ffz-balloon--md ffz-il-tooltip--wrap ffz-il-tooltip--down ffz-il-tooltip--align-right" >
2019-10-23 19:30:27 -04:00
{ { t ( 'home.changelog.about-nonversioned' , 'Non-versioned commits are commits to the FrankerFaceZ repository not associated with a release build. They typically represent maintenance or contributions from the community that will be included in a subsequent release.' ) } }
< / div >
< / div >
< / div >
2018-07-14 17:04:06 -04:00
< ul >
< li v-for = "commit of display" :key="commit.sha" class="tw-mg-b-2" >
< div class = "tw-flex tw-align-items-center tw-border-b tw-mg-b-05" >
2023-11-03 16:04:35 -04:00
< div v-if = "! addons && commit.active" class="ffz-pill tw-mg-r-05" >
2018-07-18 18:58:05 -04:00
{ { t ( 'home.changelog.current' , 'Current Version' ) } }
< / div >
2019-11-14 19:52:35 -05:00
< div v-if = "commit.title" class="tw-font-size-4" >
2018-07-14 17:04:06 -04:00
{ { commit . title } }
< / div >
2019-11-14 19:52:35 -05:00
< div v-if = "commit.author" >
< t-list
phrase = "home.changelog.by-line"
default = "By: {user}"
class = "tw-inline-flex tw-align-items-center"
>
< template # user >
< a
v - if = "commit.author.html_url"
: href = "commit.author.html_url"
target = "_blank"
rel = "noopener noreferrer"
2021-04-01 12:05:29 -04:00
class = "tw-inline-flex tw-align-items-center ffz-link ffz-link--inherit tw-mg-x-05 ffz-tooltip"
2020-08-04 18:26:11 -04:00
data - tooltip - type = "link"
2019-11-14 19:52:35 -05:00
>
< figure
v - if = "commit.author.avatar_url"
2021-02-11 19:40:12 -05:00
class = "ffz-avatar ffz-avatar--size-20 tw-mg-r-05"
2019-11-14 19:52:35 -05:00
>
< img
: src = "commit.author.avatar_url"
class = "tw-block tw-border-radius-rounded tw-image tw-image-avatar"
>
< / figure >
{ { commit . author . login } }
< / a >
< strong v -else class = "tw-mg-x-05" >
{ { commit . author . login || commit . author . name } }
< / strong >
< / template >
< / t-list >
< / div >
2018-07-14 17:04:06 -04:00
< div
v - if = "commit.hash"
class = "tw-font-size-8 tw-c-text-alt-2"
>
2021-04-01 12:05:29 -04:00
@ < a :href = "commit.link" target = "_blank" rel = "noopener noreferrer" class = "ffz-link ffz-link--inherit ffz-tooltip" data -tooltip -type = " link " > { { commit . hash } } < / a >
2018-07-14 17:04:06 -04:00
< / div >
< time
v - if = "commit.date"
: datetime = "commit.date"
class = "tw-align-right tw-flex-grow-1 tw-c-text-alt-2"
> ( { { formatDate ( commit . date ) } } ) < / time >
< / div >
< markdown :source = "commit.message" / >
< / li >
< / ul >
< div class = "tw-align-center tw-pd-1" >
< div v-if = "error" >
2020-10-14 14:55:10 -04:00
{ { t ( 'home.changelog.error' , 'An error occurred loading changes from GitHub.' ) } }
2018-07-14 17:04:06 -04:00
< / div >
< h1 v -else -if = " loading " class = "tw-mg-5 ffz-i-zreknarf loading" / >
< div v -else -if = " ! more " >
{ { t ( 'home.changelog.no-more' , 'There are no more commits to load.' ) } }
< / div >
< button v -else class = "tw-button" @click ="fetchMore" >
< div class = "tw-button__text" >
{ { t ( 'home.changelog.load' , 'Load More' ) } }
< / div >
< / button >
< / div >
2018-03-30 17:58:56 -04:00
< / div >
2017-11-13 01:23:39 -05:00
< / template >
< script >
2018-07-14 17:04:06 -04:00
import { get } from 'utilities/object' ;
2018-12-05 14:51:03 -05:00
const TITLE _MATCH = /^v?(\d+\.\d+\.\d+(?:-[^\n]+)?)\n+/ ;
2017-11-13 01:23:39 -05:00
2018-07-18 18:58:05 -04:00
2017-11-13 01:23:39 -05:00
export default {
props : [ 'item' , 'context' ] ,
2018-07-14 17:04:06 -04:00
data ( ) {
return {
error : false ,
2019-11-14 19:52:35 -05:00
addons : this . item . addons ,
2019-10-23 19:30:27 -04:00
nonversioned : false ,
2018-07-14 17:04:06 -04:00
loading : false ,
more : true ,
commits : [ ]
}
} ,
computed : {
display ( ) {
const out = [ ] ,
old _commit = this . t ( 'home.changelog.nonversioned' , 'Non-Versioned Commit' ) ;
for ( const commit of this . commits ) {
let message = commit . commit . message ,
2019-11-14 19:52:35 -05:00
author = null ,
2018-07-14 17:04:06 -04:00
title = old _commit ;
2019-11-14 19:52:35 -05:00
if ( this . addons ) {
title = null ;
author = commit . author ;
} else {
const match = TITLE _MATCH . exec ( message ) ;
2018-07-18 18:58:05 -04:00
2019-11-14 19:52:35 -05:00
if ( match ) {
title = match [ 1 ] ;
message = message . slice ( match [ 0 ] . length ) ;
} else if ( ! this . nonversioned )
continue ;
}
2019-10-23 19:30:27 -04:00
const date = new Date ( commit . commit . author . date ) ,
active = commit . sha === window . FrankerFaceZ . version _info . commit ;
2018-07-14 17:04:06 -04:00
out . push ( {
title ,
2019-11-14 19:52:35 -05:00
author ,
2018-07-14 17:04:06 -04:00
message ,
2018-07-18 18:58:05 -04:00
active ,
2018-07-14 17:04:06 -04:00
hash : commit . sha && commit . sha . slice ( 0 , 7 ) ,
link : commit . html _url ,
sha : commit . sha ,
2018-07-18 18:58:05 -04:00
date
2018-07-14 17:04:06 -04:00
} ) ;
}
return out ;
}
} ,
2018-03-30 17:58:56 -04:00
mounted ( ) {
2018-07-14 17:04:06 -04:00
this . commit _ids = new Set ;
this . fetchMore ( ) ;
2018-03-30 17:58:56 -04:00
} ,
2017-11-13 01:23:39 -05:00
methods : {
2018-07-14 17:04:06 -04:00
formatDate ( value ) {
if ( ! value )
return '' ;
const date = value instanceof Date ? value : new Date ( value ) ,
today = new Date ,
is _today = date . toDateString ( ) === today . toDateString ( ) ;
if ( is _today )
2020-08-05 19:23:18 -04:00
return this . tTime ( date ) ;
2018-07-14 17:04:06 -04:00
2020-08-05 19:23:18 -04:00
return this . tDate ( date ) ;
2018-07-14 17:04:06 -04:00
} ,
async fetchMore ( ) {
const last _commit = this . commits [ this . commits . length - 1 ] ,
until = last _commit && get ( 'commit.author.date' , last _commit ) ;
this . loading = true ;
2017-11-13 01:23:39 -05:00
2018-07-14 17:04:06 -04:00
try {
2019-11-14 19:52:35 -05:00
const resp = await fetch ( ` https://api.github.com/repos/frankerfacez/ ${ this . addons ? 'add-ons' : 'frankerfacez' } /commits ${ until ? ` ?until= ${ until } ` : '' } ` ) ,
2018-07-14 17:04:06 -04:00
data = resp . ok ? await resp . json ( ) : null ;
if ( ! data || ! Array . isArray ( data ) ) {
this . more = false ;
return ;
}
2019-11-14 19:52:35 -05:00
let added = false ;
2018-07-14 17:04:06 -04:00
for ( const commit of data ) {
if ( this . commit _ids . has ( commit . sha ) )
continue ;
this . commit _ids . add ( commit . sha )
this . commits . push ( commit ) ;
2019-11-14 19:52:35 -05:00
added = true ;
2018-07-14 17:04:06 -04:00
}
2019-11-14 19:52:35 -05:00
if ( ! added )
this . more = false ;
2018-07-14 17:04:06 -04:00
this . loading = false ;
} catch ( err ) {
this . error = true ;
}
2017-11-13 01:23:39 -05:00
}
}
}
< / script >