[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:
parent
aac97c93d0
commit
722c8b2363
|
@ -194,14 +194,11 @@ function doShowNews() {
|
|||
return 1
|
||||
esac
|
||||
|
||||
if [[ -s "$newsUnreadIdsFile" ]]; then
|
||||
local newsReadIdsFile
|
||||
newsReadIdsFile="$(newsReadIdsFile)"
|
||||
|
||||
local tempNewReadIdsFile
|
||||
tempNewReadIdsFile="$(mktemp -t hm-news-read-ids.XXXXXXXXXX)"
|
||||
|
||||
sort -u "$newsReadIdsFile" "$newsUnreadIdsFile" > "$tempNewReadIdsFile"
|
||||
mv -f "$tempNewReadIdsFile" "$newsReadIdsFile"
|
||||
cat "$newsUnreadIdsFile" >> "$newsReadIdsFile"
|
||||
fi
|
||||
}
|
||||
|
||||
function doHelp() {
|
||||
|
|
|
@ -61,8 +61,13 @@ let
|
|||
) 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" (
|
||||
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" ''
|
||||
|
|
Loading…
Reference in a new issue