[chronojump] news on view: download image if missing (solve eventual image server problem)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] news on view: download image if missing (solve eventual image server problem)
- Date: Sat, 23 Jan 2021 09:51:35 +0000 (UTC)
commit 61d8ca194c6a6a439e1b24023b06c28d4a858b3c
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Jan 23 10:50:34 2021 +0100
news on view: download image if missing (solve eventual image server problem)
diagrams/processes/news.dia | Bin 5834 -> 5857 bytes
src/gui/app1/news.cs | 20 ++++++++++++++++----
src/news.cs | 17 +++++++++++++++++
3 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/diagrams/processes/news.dia b/diagrams/processes/news.dia
index dc646532..c4120050 100644
Binary files a/diagrams/processes/news.dia and b/diagrams/processes/news.dia differ
diff --git a/src/gui/app1/news.cs b/src/gui/app1/news.cs
index 0c9f0c91..93fd6be8 100644
--- a/src/gui/app1/news.cs
+++ b/src/gui/app1/news.cs
@@ -54,14 +54,26 @@ public partial class ChronoJumpWindow
// 1) select the news locally
newsAtDB_l = SqliteNews.Select(false, -1, 10);
- // 2) prepare the GUI
+ // 2) check if any of the images is missing (because or images server is down or any other
reason)
+ bool allImagesSaved = true;
+ foreach(News news in newsAtDB_l)
+ if(! news.ImageSavedOnDisc)
+ {
+ allImagesSaved = false;
+ break;
+ }
+
+
+ // 3) prepare the GUI
alignment_news.Show(); // is hidden at beginning to allow being well shown when filled
menus_and_mode_sensitive(false);
app1s_notebook_sup_entered_from = notebook_sup.CurrentPage;
notebook_sup.CurrentPage = Convert.ToInt32(notebook_sup_pages.NEWS);
- // 3) get the news on the server
- if(preferences.serverNewsDatetime != "" && preferences.serverNewsDatetime !=
preferences.clientNewsDatetime)
+ // 4) get the news on the server and/or display them
+ if(
+ (preferences.serverNewsDatetime != "" && preferences.serverNewsDatetime !=
preferences.clientNewsDatetime)
+ || allImagesSaved == false )
{
newsDownloadCancel = false;
LogB.Information("newsGet thread will start");
@@ -69,7 +81,7 @@ public partial class ChronoJumpWindow
GLib.Idle.Add (new GLib.IdleHandler (pulseNewsGetGTK));
pingThread.Start();
} else {
- // 3b) or display old news
+ // 4b) or display old news
newsDisplay();
}
}
diff --git a/src/news.cs b/src/news.cs
index 79b14744..f0185a46 100644
--- a/src/news.cs
+++ b/src/news.cs
@@ -185,6 +185,23 @@ public class News
"\" WHERE code = " + code;
}
+ //check if the image is saved or not, to download it if there where any problems on the server
+ public bool ImageSavedOnDisc
+ {
+ get {
+ if(linkServerImage == "")
+ return false;
+
+ string extension = "";
+ if(Util.IsJpeg(linkServerImage))
+ extension = ".jpg";
+ else if (Util.IsPng(linkServerImage))
+ extension = ".png";
+
+ return (File.Exists(Path.Combine(News.GetNewsDir(), code.ToString() + extension)));
+ }
+ }
+
public int Code
{
get { return code; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]