Skip to content

Commit

Permalink
setting to disable last fetch mark (for development) + bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartones committed Aug 28, 2021
1 parent 63eceba commit 42194b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 9 additions & 3 deletions pbrr/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

from pbrr.log import Log

# For development, debugging, etc.
SET_LAST_FETCH_MARK = False

SETTINGS_FILENAME = "settings.json"
KEY_LAST_FETCH = "last_fetch"
# domains to skip (e.g. can't fetch right now via pbrr). to be manually added editing the settings json
Expand All @@ -30,7 +33,7 @@ def load(self) -> None:
data = json.load(file_handle)

last_fetch = data.get(KEY_LAST_FETCH, None)
if last_fetch:
if last_fetch and SET_LAST_FETCH_MARK:
self.last_fetch_mark = datetime.utcfromtimestamp(last_fetch)
Log.info("> Previous fetch mark was: {}".format(self.last_fetch_mark))

Expand All @@ -49,7 +52,7 @@ def save(self) -> None:
Log.error_and_exit("Output path '{}' not found".format(self.base_output_path))

data = {
KEY_LAST_FETCH: fetch_mark.timestamp(),
KEY_LAST_FETCH: fetch_mark.timestamp() if SET_LAST_FETCH_MARK else None,
KEY_SKIP_URLS: self.skip_urls,
KEY_EMOJI_ICONS: self.category_icons,
KEY_SKIP_FILTERS: self.skip_filters,
Expand All @@ -58,4 +61,7 @@ def save(self) -> None:
with open(file_path, "w") as file_handle:
json.dump(data, file_handle, indent=None)

Log.info("> Fetch mark set to: {}".format(fetch_mark))
if SET_LAST_FETCH_MARK:
Log.info("> Fetch mark set to: {}".format(fetch_mark))
else:
Log.info("> Fetch mark skipped")
6 changes: 4 additions & 2 deletions pbrr/templates/js/pbrr.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
feedNode[0].dataset.currentEntries.length > 0 ? feedNode[0].dataset.currentEntries.split(",") : [];
const currentReadEntries = readFeedData(feedNode[0].id);

if (currentEntries.length === 0 || currentReadEntries.size >= currentEntries.length) {
// No data returned from server, or no new entries
if (currentEntries.length === 0
|| currentEntries.filter(entry => !currentReadEntries.has(entry)).length === 0) {
spanNode.hide();
} else {
parentDivNode.collapse("show");
Expand Down Expand Up @@ -77,7 +79,7 @@
}
}

if (currentReadEntries.size >= entries.length) {
if (entries.filter(entry => !currentReadEntries.has(entry)).length === 0) {
document.getElementById(feedId)
.getElementsByClassName("last-update-date")[0]
.classList
Expand Down

0 comments on commit 42194b7

Please sign in to comment.