@@ -21,6 +21,7 @@ public class DepartmentSettingsService : IDepartmentSettingsService
2121 private static string StaffingSupressInfo = "DSetStaffingSupress_{0}" ;
2222 private static string TtsLanguageCacheKey = "DSetTtsLanguage_{0}" ;
2323 private static string PersonnelOnUnitSetUnitStatusCacheKey = "DSetPersonnelOnUnitSetUnitStatus_{0}" ;
24+ private static string ModernNotificationsCacheKey = "DSetModernNotifications_{0}" ;
2425 private static TimeSpan LongCacheLength = TimeSpan . FromDays ( 14 ) ;
2526 private static TimeSpan ThatsNotLongThisIsLongCacheLength = TimeSpan . FromDays ( 365 ) ;
2627 private static TimeSpan TwoYearCacheLength = TimeSpan . FromDays ( 730 ) ;
@@ -72,6 +73,9 @@ public DepartmentSettingsService(IDepartmentSettingsRepository departmentSetting
7273 case DepartmentSettingTypes . PersonnelOnUnitSetUnitStatus :
7374 await _cacheProvider . RemoveAsync ( string . Format ( PersonnelOnUnitSetUnitStatusCacheKey , departmentId ) ) ;
7475 break ;
76+ case DepartmentSettingTypes . EnableModernNotifications :
77+ await _cacheProvider . RemoveAsync ( string . Format ( ModernNotificationsCacheKey , departmentId ) ) ;
78+ break ;
7579 }
7680
7781 savedSetting . Setting = setting ;
@@ -924,14 +928,21 @@ public async Task<DepartmentSetting> GetSettingByTypeAsync(int departmentId, Dep
924928 return await GetSettingByDepartmentIdType ( departmentId , type ) ;
925929 }
926930
927- public async Task < bool > GetModernNotificationsEnabledAsync ( int departmentId )
931+ public async Task < bool > GetModernNotificationsEnabledAsync ( int departmentId , bool bypassCache = false )
928932 {
929- var s = await GetSettingByDepartmentIdType ( departmentId , DepartmentSettingTypes . EnableModernNotifications ) ;
933+ async Task < string > getSetting ( )
934+ {
935+ var s = await GetSettingByDepartmentIdType ( departmentId , DepartmentSettingTypes . EnableModernNotifications ) ;
936+ return s ? . Setting ?? "false" ;
937+ }
930938
931- if ( s != null && bool . TryParse ( s . Setting , out bool result ) )
932- return result ;
939+ if ( Config . SystemBehaviorConfig . CacheEnabled && ! bypassCache )
940+ {
941+ var cachedValue = await _cacheProvider . RetrieveAsync < string > ( string . Format ( ModernNotificationsCacheKey , departmentId ) , getSetting , LongCacheLength ) ;
942+ return bool . Parse ( cachedValue ) ;
943+ }
933944
934- return false ;
945+ return bool . Parse ( await getSetting ( ) ) ;
935946 }
936947
937948 private static string GetDefaultTtsLanguage ( )
0 commit comments