Console: Add initial news to bottom of news page so it doesn't disappear (ticket #1153)

This commit is contained in:
zzz
2016-11-13 15:56:47 +00:00
parent 3ac8e5f54f
commit efd953f3d4
2 changed files with 25 additions and 1 deletions

View File

@ -172,6 +172,23 @@ public class NewsManager implements ClientApp {
return parseNews(newsContent, false);
}
/**
* The initial (welcome to i2p) news
*
* @return entry with first-installed date stamp, or null
* @since 0.9.28
*/
public NewsEntry getInitialNews() {
List<NewsEntry> list = parseInitialNews();
if (list.isEmpty())
return null;
NewsEntry rv = list.get(0);
long installed = _context.getProperty("router.firstInstalled", 0L);
if (installed > 0)
rv.updated = installed;
return rv;
}
private List<NewsEntry> parseInitialNews() {
NewsEntry entry = new NewsEntry();
File file = new File(_context.getBaseDir(), "docs/initialNews/initialNews.xml");

View File

@ -50,8 +50,15 @@ public class NewsFeedHelper extends HelperBase {
ClientAppManager cmgr = ctx.clientAppManager();
if (cmgr != null) {
NewsManager nmgr = (NewsManager) cmgr.getRegisteredApp(NewsManager.APP_NAME);
if (nmgr != null)
if (nmgr != null) {
entries = nmgr.getEntries();
NewsEntry init = nmgr.getInitialNews();
if (init != null) {
// crude check to see if it's already in there
if (entries.size() != 1 || !DataHelper.eq(entries.get(0).title, init.title))
entries.add(init);
}
}
}
if (!entries.isEmpty()) {
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);