[FIXUP] Append unread news items

It's always guaranteed that unread news items from 'newsUnreadIdsFile'
are not already present in 'newsUnreadIdsFile'. Thanks @nonsequitur!
This commit is contained in:
Robert Helgesson 2017-09-04 22:38:26 +02:00
parent aac97c93d0
commit 722c8b2363
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86
2 changed files with 11 additions and 9 deletions

View file

@ -194,14 +194,11 @@ function doShowNews() {
return 1 return 1
esac esac
if [[ -s "$newsUnreadIdsFile" ]]; then
local newsReadIdsFile local newsReadIdsFile
newsReadIdsFile="$(newsReadIdsFile)" newsReadIdsFile="$(newsReadIdsFile)"
cat "$newsUnreadIdsFile" >> "$newsReadIdsFile"
local tempNewReadIdsFile fi
tempNewReadIdsFile="$(mktemp -t hm-news-read-ids.XXXXXXXXXX)"
sort -u "$newsReadIdsFile" "$newsUnreadIdsFile" > "$tempNewReadIdsFile"
mv -f "$tempNewReadIdsFile" "$newsReadIdsFile"
} }
function doHelp() { function doHelp() {

View file

@ -61,8 +61,13 @@ let
) env.newsEntries ) env.newsEntries
); );
# File where each line corresponds to an unread news entry
# identifier. If non-empty then the file ends in "\n".
newsUnreadIdsFile = pkgs.writeText "news-unread-ids" ( newsUnreadIdsFile = pkgs.writeText "news-unread-ids" (
concatMapStringsSep "\n" (entry: entry.id) newsFiltered let
text = concatMapStringsSep "\n" (entry: entry.id) newsFiltered;
in
text + optionalString (text != "") "\n"
); );
newsInfo = pkgs.writeText "news-info.sh" '' newsInfo = pkgs.writeText "news-info.sh" ''