Skip to content

Commit 517a4b7

Browse files
committed
add app upadate feture
1 parent b6f1b04 commit 517a4b7

21 files changed

Lines changed: 528 additions & 116 deletions

documentation/components/AppComponent.html

Lines changed: 99 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ <h6><b>Methods</b></h6>
252252
<span class="modifier">Private</span>
253253
<a href="#generateUserId" >generateUserId</a>
254254
</li>
255+
<li>
256+
<a href="#isAppUpdated" >isAppUpdated</a>
257+
</li>
255258
<li>
256259
<a href="#ngOnInit" >ngOnInit</a>
257260
</li>
@@ -298,12 +301,12 @@ <h3 id="constructor">Constructor</h3>
298301
<tbody>
299302
<tr>
300303
<td class="col-md-4">
301-
<code>constructor(userService: <a href="../injectables/UserService.html" target="_self">UserService</a>, loader: <a href="../injectables/GlobalLoaderService.html" target="_self">GlobalLoaderService</a>, sectionService: <a href="../injectables/SectionService.html" target="_self">SectionService</a>, storageService: <a href="../injectables/StorageService.html" target="_self">StorageService</a>, router: Router, postApiService: <a href="../injectables/PostApiService.html" target="_self">PostApiService</a>, platformId: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" target="_blank">Object</a>)</code>
304+
<code>constructor(userService: <a href="../injectables/UserService.html" target="_self">UserService</a>, loader: <a href="../injectables/GlobalLoaderService.html" target="_self">GlobalLoaderService</a>, sectionService: <a href="../injectables/SectionService.html" target="_self">SectionService</a>, storageService: <a href="../injectables/StorageService.html" target="_self">StorageService</a>, router: Router, postApiService: <a href="../injectables/PostApiService.html" target="_self">PostApiService</a>, toastService: <a href="../injectables/ToastService.html" target="_self">ToastService</a>, platformId: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" target="_blank">Object</a>)</code>
302305
</td>
303306
</tr>
304307
<tr>
305308
<td class="col-md-4">
306-
<div class="io-line">Defined in <a href="" data-line="66" class="link-to-prism">src/app/app.component.ts:66</a></div>
309+
<div class="io-line">Defined in <a href="" data-line="67" class="link-to-prism">src/app/app.component.ts:67</a></div>
307310
</td>
308311
</tr>
309312

@@ -420,6 +423,22 @@ <h3 id="constructor">Constructor</h3>
420423

421424
</td>
422425
</tr>
426+
<tr>
427+
<td>toastService</td>
428+
429+
<td>
430+
<code><a href="../injectables/ToastService.html" target="_self" >ToastService</a></code>
431+
</td>
432+
433+
<td>
434+
No
435+
</td>
436+
437+
<td>
438+
<p>Service for displaying toast notifications</p>
439+
440+
</td>
441+
</tr>
423442
<tr>
424443
<td>platformId</td>
425444

@@ -474,8 +493,8 @@ <h3>HostListeners</h3> <table class="table table-sm table-bordered">
474493

475494
<tr>
476495
<td class="col-md-4">
477-
<div class="io-line">Defined in <a href="" data-line="160"
478-
class="link-to-prism">src/app/app.component.ts:160</a></div>
496+
<div class="io-line">Defined in <a href="" data-line="170"
497+
class="link-to-prism">src/app/app.component.ts:170</a></div>
479498
</td>
480499
</tr>
481500

@@ -542,8 +561,8 @@ <h3>HostListeners</h3> <table class="table table-sm table-bordered">
542561

543562
<tr>
544563
<td class="col-md-4">
545-
<div class="io-line">Defined in <a href="" data-line="149"
546-
class="link-to-prism">src/app/app.component.ts:149</a></div>
564+
<div class="io-line">Defined in <a href="" data-line="159"
565+
class="link-to-prism">src/app/app.component.ts:159</a></div>
547566
</td>
548567
</tr>
549568

@@ -613,8 +632,8 @@ <h3 id="methods">
613632

614633
<tr>
615634
<td class="col-md-4">
616-
<div class="io-line">Defined in <a href="" data-line="168"
617-
class="link-to-prism">src/app/app.component.ts:168</a></div>
635+
<div class="io-line">Defined in <a href="" data-line="178"
636+
class="link-to-prism">src/app/app.component.ts:178</a></div>
618637
</td>
619638
</tr>
620639

@@ -636,6 +655,49 @@ <h3 id="methods">
636655
</tr>
637656
</tbody>
638657
</table>
658+
<table class="table table-sm table-bordered">
659+
<tbody>
660+
<tr>
661+
<td class="col-md-4">
662+
<a name="isAppUpdated"></a>
663+
<span class="name">
664+
<span ><b>isAppUpdated</b></span>
665+
<a href="#isAppUpdated"><span class="icon ion-ios-link"></span></a>
666+
</span>
667+
</td>
668+
</tr>
669+
<tr>
670+
<td class="col-md-4">
671+
<code>isAppUpdated()</code>
672+
</td>
673+
</tr>
674+
675+
676+
<tr>
677+
<td class="col-md-4">
678+
<div class="io-line">Defined in <a href="" data-line="188"
679+
class="link-to-prism">src/app/app.component.ts:188</a></div>
680+
</td>
681+
</tr>
682+
683+
684+
<tr>
685+
<td class="col-md-4">
686+
<div class="io-description"><p>Checks if the application is updated.</p>
687+
</div>
688+
689+
<div class="io-description">
690+
<b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code>
691+
692+
</div>
693+
<div class="io-description">
694+
<p>True if the app is updated, false otherwise.</p>
695+
696+
</div>
697+
</td>
698+
</tr>
699+
</tbody>
700+
</table>
639701
<table class="table table-sm table-bordered">
640702
<tbody>
641703
<tr>
@@ -656,8 +718,8 @@ <h3 id="methods">
656718

657719
<tr>
658720
<td class="col-md-4">
659-
<div class="io-line">Defined in <a href="" data-line="110"
660-
class="link-to-prism">src/app/app.component.ts:110</a></div>
721+
<div class="io-line">Defined in <a href="" data-line="113"
722+
class="link-to-prism">src/app/app.component.ts:113</a></div>
661723
</td>
662724
</tr>
663725

@@ -705,8 +767,8 @@ <h3 id="methods">
705767

706768
<tr>
707769
<td class="col-md-4">
708-
<div class="io-line">Defined in <a href="" data-line="149"
709-
class="link-to-prism">src/app/app.component.ts:149</a></div>
770+
<div class="io-line">Defined in <a href="" data-line="159"
771+
class="link-to-prism">src/app/app.component.ts:159</a></div>
710772
</td>
711773
</tr>
712774

@@ -788,8 +850,8 @@ <h3 id="methods">
788850

789851
<tr>
790852
<td class="col-md-4">
791-
<div class="io-line">Defined in <a href="" data-line="160"
792-
class="link-to-prism">src/app/app.component.ts:160</a></div>
853+
<div class="io-line">Defined in <a href="" data-line="170"
854+
class="link-to-prism">src/app/app.component.ts:170</a></div>
793855
</td>
794856
</tr>
795857

@@ -872,7 +934,7 @@ <h3 id="inputs">
872934
</tr>
873935
<tr>
874936
<td class="col-md-4">
875-
<div class="io-line">Defined in <a href="" data-line="51" class="link-to-prism">src/app/app.component.ts:51</a></div>
937+
<div class="io-line">Defined in <a href="" data-line="52" class="link-to-prism">src/app/app.component.ts:52</a></div>
876938
</td>
877939
</tr>
878940

@@ -903,7 +965,7 @@ <h3 id="inputs">
903965
</tr>
904966
<tr>
905967
<td class="col-md-4">
906-
<div class="io-line">Defined in <a href="" data-line="61" class="link-to-prism">src/app/app.component.ts:61</a></div>
968+
<div class="io-line">Defined in <a href="" data-line="62" class="link-to-prism">src/app/app.component.ts:62</a></div>
907969
</td>
908970
</tr>
909971

@@ -940,7 +1002,7 @@ <h3 id="inputs">
9401002
</tr>
9411003
<tr>
9421004
<td class="col-md-4">
943-
<div class="io-line">Defined in <a href="" data-line="56" class="link-to-prism">src/app/app.component.ts:56</a></div>
1005+
<div class="io-line">Defined in <a href="" data-line="57" class="link-to-prism">src/app/app.component.ts:57</a></div>
9441006
</td>
9451007
</tr>
9461008

@@ -971,7 +1033,7 @@ <h3 id="inputs">
9711033
</tr>
9721034
<tr>
9731035
<td class="col-md-4">
974-
<div class="io-line">Defined in <a href="" data-line="66" class="link-to-prism">src/app/app.component.ts:66</a></div>
1036+
<div class="io-line">Defined in <a href="" data-line="67" class="link-to-prism">src/app/app.component.ts:67</a></div>
9751037
</td>
9761038
</tr>
9771039

@@ -1004,7 +1066,7 @@ <h3 id="inputs">
10041066
</tr>
10051067
<tr>
10061068
<td class="col-md-4">
1007-
<div class="io-line">Defined in <a href="" data-line="82" class="link-to-prism">src/app/app.component.ts:82</a></div>
1069+
<div class="io-line">Defined in <a href="" data-line="84" class="link-to-prism">src/app/app.component.ts:84</a></div>
10081070
</td>
10091071
</tr>
10101072

@@ -1049,6 +1111,7 @@ <h3 id="inputs">
10491111
import { GlobalLoaderService } from &#x27;./service/global-loader/global-loader.service&#x27;;
10501112
import { SectionService } from &#x27;./service/section/section.service&#x27;;
10511113
import { PostApiService } from &#x27;./service/backend-api/post/post-api.service&#x27;;
1114+
import { ToastService } from &#x27;./service/toast/toast.service&#x27;;
10521115

10531116
/**
10541117
* Root component of the application.
@@ -1101,6 +1164,7 @@ <h3 id="inputs">
11011164
* @param postApiService Backend API post service
11021165
* @param swUpdate Service Worker update manager
11031166
* @param platformId Angular platform ID to check if running in browser
1167+
* @param toastService Service for displaying toast notifications
11041168
*/
11051169
constructor(
11061170
public userService: UserService,
@@ -1109,6 +1173,7 @@ <h3 id="inputs">
11091173
private storageService: StorageService,
11101174
private router: Router,
11111175
private postApiService: PostApiService,
1176+
private toastService: ToastService,
11121177
@Inject(PLATFORM_ID) private platformId: Object
11131178
) {
11141179

@@ -1162,6 +1227,13 @@ <h3 id="inputs">
11621227
} else {
11631228
this.postApiService.postUserData();
11641229
}
1230+
1231+
// Show update toast if app is not updated
1232+
if (!this.isAppUpdated()) {
1233+
setTimeout(() &#x3D;&gt; {
1234+
this.toastService.show(&#x27;🚀 Update available! Please update from ⚙️ Settings.&#x27;, &#x27;info&#x27;, 5000);
1235+
}, 500);
1236+
}
11651237
}
11661238
}
11671239

@@ -1194,6 +1266,14 @@ <h3 id="inputs">
11941266
const random &#x3D; Math.random().toString(36).substring(2, 10);
11951267
return &#x60;${timestamp}-${random}&#x60;;
11961268
}
1269+
1270+
/**
1271+
* Checks if the application is updated.
1272+
* @returns True if the app is updated, false otherwise.
1273+
*/
1274+
isAppUpdated(): boolean {
1275+
return this.userService.getValue&lt;boolean&gt;(&#x27;is_app_updated&#x27;) ?? false;
1276+
}
11971277
}
11981278
</code></pre>
11991279
</div>

documentation/components/SettingsComponent.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,9 +1958,11 @@ <h3 id="inputs">
19581958
caches.keys().then((names: string[]) &#x3D;&gt; {
19591959
names.forEach(name &#x3D;&gt; caches.delete(name));
19601960
}).finally(() &#x3D;&gt; {
1961-
(window as Window).location.reload(); // ✅ cast fixes TS error
1961+
this.userService.update(&#x27;is_app_updated&#x27;, true);
1962+
(window as Window).location.reload();
19621963
});
19631964
} else {
1965+
this.userService.update(&#x27;is_app_updated&#x27;, true);
19641966
(window as Window).location.reload();
19651967
}
19661968
}

0 commit comments

Comments
 (0)