Skip to content

Commit

Permalink
Implement skip repos option
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Jul 3, 2021
1 parent 42a9e9f commit 8209874
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions webext/data/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const _logName = 'lovely-forks:'
const STAR_THRES_KEY = 'STAR_THRES_KEY'
const SKIP_REPOS_KEY = 'SKIP_REPOS_KEY'
const INDENT_KEY = 'INDENT_KEY'
const LF_PREF_KEY = 'LF_PREF_KEY'
const DAYS_THRES_KEY = 'DAYS_THRES_KEY'
Expand All @@ -20,6 +21,7 @@ function getPreferences () {
x = x[LF_PREF_KEY] || {}

pref[STAR_THRES_KEY] = x[STAR_THRES_KEY] || 1
pref[SKIP_REPOS_KEY] = x[SKIP_REPOS_KEY] || ""
pref[DAYS_THRES_KEY] = x[DAYS_THRES_KEY] || 0
pref[INDENT_KEY] = x[INDENT_KEY] || false

Expand Down Expand Up @@ -218,6 +220,13 @@ function isQuotaExceeded (e) {
function processWithData (user, repo, remoteDataStr,
selfDataStr, isFreshData, pref) {
try {
/* Skip displaying if the repo is in the skip list */
const skipRepos = pref[SKIP_REPOS_KEY].split(/[\s\n,]+/)
const inSkipList = skipRepos.some(val => val.indexOf(user + "/" + repo) > -1)
if (inSkipList) {
return
}

/* Parse fork data */
/* Can either be just one data element,
* or could be the list of all forks. */
Expand Down
6 changes: 6 additions & 0 deletions webext/options_ui/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@

const DEBUG = false
const STAR_THRES_KEY = 'STAR_THRES_KEY'
const SKIP_REPOS_KEY = 'SKIP_REPOS_KEY'
const INDENT_KEY = 'INDENT_KEY'
const LF_PREF_KEY = 'LF_PREF_KEY'
const DAYS_THRES_KEY = 'DAYS_THRES_KEY'

chrome.storage.local.get(LF_PREF_KEY, x => {
x = x[LF_PREF_KEY] || {}
const thres = x[STAR_THRES_KEY] || 1
const skipRepos = x[SKIP_REPOS_KEY] || ""
const dayThres = x[DAYS_THRES_KEY] || 0
const indent = x[INDENT_KEY] || false
$('.js-star-threshold').val(thres)
$('.js-skip-repos').val(skipRepos)
$('.js-days-threshold').val(dayThres)
$('.js-to-indent').checkbox(indent ? 'set checked' : 'set unchecked')
})

function savePref () {
const thres = $('.js-star-threshold').val() || 0
const skipRepos = $('.js-skip-repos').val() || ""
const dayThres = $('.js-days-threshold').val() || 0
const indent = $('.js-to-indent').checkbox('is checked') || false
const pref = {
[INDENT_KEY]: indent,
[STAR_THRES_KEY]: thres,
[SKIP_REPOS_KEY]: skipRepos,
[DAYS_THRES_KEY]: dayThres
}
chrome.storage.local.set({ [LF_PREF_KEY]: pref }, () => {
Expand All @@ -39,4 +44,5 @@ function savePref () {

$('.js-to-indent.ui.checkbox').checkbox({ onChange: savePref })
$('.js-star-threshold').on('change', savePref)
$('.js-skip-repos').on('change', savePref)
$('.js-days-threshold').on('change', savePref)
10 changes: 10 additions & 0 deletions webext/options_ui/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ <h1 class="ui block header">
</div>
</section>

<section class="ui settings basic segment">
<p>Repos on which to skip showing forks (comma, space, or newline separated list)</p>
<div class="ui form">
<div class="ui field">
<label for="skip_repos">Repos to skip:</label>
<textarea id="skip_repos" class="js-skip-repos">
</div>
</div>
</section>

<section class="ui settings basic segment">
<p>Only show message when last commit in base repo is older than?</p>
<div class="ui form">
Expand Down

0 comments on commit 8209874

Please sign in to comment.