From 86775586fe278d49063b3d2411610737bfe2dd2f Mon Sep 17 00:00:00 2001 From: acanas Date: Tue, 23 Feb 2021 09:36:45 +0100 Subject: [PATCH] Version 20.34.1: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (305009 lines) --- swad_changelog.h | 3 +- swad_text.c | 2 +- swad_timeline_favourite.c | 78 +++++++++++++++++++-------------------- swad_timeline_share.c | 37 +++++++++---------- 4 files changed, 59 insertions(+), 61 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index dc5db8ce0..9cdde77d6 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 20.34 (2021-02-23)" +#define Log_PLATFORM_VERSION "SWAD 20.34.1 (2021-02-23)" #define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* @@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede. TODO: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.34.1: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (305009 lines) Version 20.34: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (305011 lines) Version 20.33.11: Feb 23, 2021 Code refactoring in timeline. (305001 lines) Version 20.33.10: Feb 23, 2021 Code refactoring related to writing a timeline notes and comments. (305038 lines) diff --git a/swad_text.c b/swad_text.c index fcb13332f..3a128b333 100644 --- a/swad_text.c +++ b/swad_text.c @@ -19077,7 +19077,7 @@ const char *Txt_Mark_all_NOTIFICATIONS_as_read = "Marcar todas como lidas"; #endif -const char *Txt_Mark_as_favourite = +const char *Txt_TIMELINE_Mark_as_favourite = #if L==1 // ca "Marca com favorit"; #elif L==2 // de diff --git a/swad_timeline_favourite.c b/swad_timeline_favourite.c index 24fc32be5..d171fc432 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -409,30 +409,29 @@ static void TL_Fav_PutDisabledIconFav (unsigned NumFavs) static void TL_Fav_PutFormToFavUnfNote (long NotCod) { extern const char *Txt_TIMELINE_Favourite; - extern const char *Txt_Mark_as_favourite; - TL_Frm_Action_t Action; - const char *Icon; - const char *Title; + extern const char *Txt_TIMELINE_Mark_as_favourite; + bool FavUnf; + static TL_Frm_Action_t Action[2] = + { + TL_Frm_FAV_NOTE, // Not faved ==> fav + TL_Frm_UNF_NOTE, // Faved ==> unfav + }; + static const char *Icon[2] = + { + TL_Fav_ICON_FAV, // Not faved ==> put icon to fav + TL_Fav_ICON_FAVED, // Faved ==> put icon to unfav + }; + const char *Title[2] = + { + Txt_TIMELINE_Mark_as_favourite, // Not faved ==> put text to fav + Txt_TIMELINE_Favourite, // Faved ==> put text to unfav + }; /***** Select whether fav/unfav *****/ - if (TL_Fav_CheckIfNoteIsFavedByUsr (NotCod, - Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited this note - { - /* Faved ==> put form and icon to unfav */ - Action = TL_Frm_UNF_NOTE; - Icon = TL_Fav_ICON_FAVED; - Title = Txt_TIMELINE_Favourite; - } - else - { - /* Not faved ==> put form and icon to fav */ - Action = TL_Frm_FAV_NOTE; - Icon = TL_Fav_ICON_FAV; - Title = Txt_Mark_as_favourite; - } + FavUnf = TL_Fav_CheckIfNoteIsFavedByUsr (NotCod,Gbl.Usrs.Me.UsrDat.UsrCod); // I have favourited this note /***** Form and icon to fav/unfav note *****/ - TL_Frm_FormFavSha (Action,"NotCod=%ld",NotCod,Icon,Title); + TL_Frm_FormFavSha (Action[FavUnf],"NotCod=%ld",NotCod,Icon[FavUnf],Title[FavUnf]); } /*****************************************************************************/ @@ -442,30 +441,29 @@ static void TL_Fav_PutFormToFavUnfNote (long NotCod) static void TL_Fav_PutFormToFavUnfComm (long PubCod) { extern const char *Txt_TIMELINE_Favourite; - extern const char *Txt_Mark_as_favourite; - TL_Frm_Action_t Action; - const char *Icon; - const char *Title; + extern const char *Txt_TIMELINE_Mark_as_favourite; + bool FavUnf; + static TL_Frm_Action_t Action[2] = + { + TL_Frm_FAV_COMM, // Not faved ==> fav + TL_Frm_UNF_COMM, // Faved ==> unfav + }; + static const char *Icon[2] = + { + TL_Fav_ICON_FAV, // Not faved ==> put icon to fav + TL_Fav_ICON_FAVED, // Faved ==> put icon to unfav + }; + const char *Title[2] = + { + Txt_TIMELINE_Mark_as_favourite, // Not faved ==> put text to fav + Txt_TIMELINE_Favourite, // Faved ==> put text to unfav + }; /***** Select whether fav/unfav *****/ - if (TL_Fav_CheckIfCommIsFavedByUsr (PubCod, - Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited this comment - { - /* Faved ==> put form and icon to unfav */ - Action = TL_Frm_UNF_COMM; - Icon = TL_Fav_ICON_FAVED; - Title = Txt_TIMELINE_Favourite; - } - else - { - /* Not faved ==> put form and icon to fav */ - Action = TL_Frm_FAV_COMM; - Icon = TL_Fav_ICON_FAV; - Title = Txt_Mark_as_favourite; - } + FavUnf = TL_Fav_CheckIfNoteIsFavedByUsr (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod); // I have favourited this comment /***** Form and icon to fav/unfav *****/ - TL_Frm_FormFavSha (Action,"PubCod=%ld",PubCod,Icon,Title); + TL_Frm_FormFavSha (Action[FavUnf],"PubCod=%ld",PubCod,Icon[FavUnf],Title[FavUnf]); } /*****************************************************************************/ diff --git a/swad_timeline_share.c b/swad_timeline_share.c index 65ce34c68..03eb6d163 100644 --- a/swad_timeline_share.c +++ b/swad_timeline_share.c @@ -254,29 +254,28 @@ static void TL_Sha_PutFormToShaUnsNote (long NotCod) { extern const char *Txt_TIMELINE_Shared; extern const char *Txt_TIMELINE_Share; - TL_Frm_Action_t Action; - const char *Icon; - const char *Title; + bool ShaUns; + static TL_Frm_Action_t Action[2] = + { + TL_Frm_SHA_NOTE, // Not shared ==> share + TL_Frm_UNS_NOTE, // Shared ==> unshare + }; + static const char *Icon[2] = + { + TL_Sha_ICON_SHARE, // Not shared ==> put icon to share + TL_Sha_ICON_SHARED, // Shared ==> put icon to unshare + }; + const char *Title[2] = + { + Txt_TIMELINE_Share, // Not shared ==> put text to share + Txt_TIMELINE_Shared, // Shared ==> put text to unshare + }; /***** Select whether share/unshare *****/ - if (TL_Sha_CheckIfNoteIsSharedByUsr (NotCod, - Gbl.Usrs.Me.UsrDat.UsrCod)) // I have shared this note - { - /* Shared ==> put form and icon to unshare */ - Action = TL_Frm_UNS_NOTE; - Icon = TL_Sha_ICON_SHARED; - Title = Txt_TIMELINE_Shared; - } - else - { - /* Not shared ==> put form and icon to share */ - Action = TL_Frm_SHA_NOTE; - Icon = TL_Sha_ICON_SHARE; - Title = Txt_TIMELINE_Share; - } + ShaUns = TL_Sha_CheckIfNoteIsSharedByUsr (NotCod,Gbl.Usrs.Me.UsrDat.UsrCod); // I have shared this note /***** Form and icon to share/unshare note *****/ - TL_Frm_FormFavSha (Action,"NotCod=%ld",NotCod,Icon,Title); + TL_Frm_FormFavSha (Action[ShaUns],"NotCod=%ld",NotCod,Icon[ShaUns],Title[ShaUns]); } /*****************************************************************************/