[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
|
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() {
|
||||||
|
|
|
@ -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" ''
|
||||||
|
|
Loading…
Reference in a new issue