Skip to content

Commit

Permalink
refactor:improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Dec 9, 2023
1 parent 3f63537 commit b9f9cb7
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/app/about/about.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ion-toolbar>
</ion-header>

<ion-content padding>
<ion-content class="width-80">
<article>
<p>
The Harvard Universal Classics, originally known as Dr. Eliot's Five Foot Shelf, is a 51-volume anthology of
Expand Down
2 changes: 1 addition & 1 deletion src/app/month/month.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ion-toolbar>
</ion-header>

<ion-content #content class="ion-padding">
<ion-content #content class="ion-padding width-80">
<ion-calendar #calendar
(select)="onSelect($event)"
[(ngModel)]="dateMulti"
Expand Down
4 changes: 2 additions & 2 deletions src/app/notes/notes.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export class NotesPage implements OnInit {
const userNotes = data.notes;
this.notes = [];
userNotes.forEach(note => {
const month = note.day.substr(0, 2);
const day = note.day.substr(3, 2);
const month = note.day.substring(0, 2);
const day = note.day.substring(3, 2);
const key = '2016-' + note.day;
this.notes[key] = this.notes[key] || [];
this.notes[key].push({
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AnalyticsProvider {
clientId: localStorage.getItem('ga:clientId')
});
ga('set', 'appName', APPLICATION_NAME);
ga('set', 'checkProtocolTask', null);
ga('set', 'checkProtocolTask', null);
ga('set', 'transportUrl', 'https://www.google-analytics.com/collect');
ga(function (tracker) {
if (!localStorage.getItem('ga:clientId')) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class Events {
private c = new Map<string, EventHandler[]>();

constructor() {
// console.warn(`[DEPRECATION][Events]: The Events provider is deprecated and it will be removed in the next major release.
// console.warn(`[DEPRECATION][Events]: The Events provider is deprecated, and it will be removed in the next major release.
// - Use "Observables" for a similar pub/sub architecture: https://angular.io/guide/observables
// - Use "Redux" for advanced state management: https://ngrx.io`);
}
Expand All @@ -18,7 +18,7 @@ export class Events {
* Subscribe to an event topic. Events that get posted to that topic will trigger the provided handler.
*
* @param topic the topic to subscribe to
* @param handler the event handler
* @param handlers the event handler
*/
subscribe(topic: any, ...handlers: EventHandler[]) {
let topics = this.c.get(topic);
Expand Down Expand Up @@ -64,7 +64,7 @@ export class Events {
* Publish an event to the given topic.
*
* @param topic the topic to publish to
* @param eventData the data to send as the event
* @param args the data to send as the event
*/
publish(topic: string, ...args: any[]): any[] | null {
const topics = this.c.get(topic);
Expand Down
14 changes: 7 additions & 7 deletions src/app/services/material.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {lastValueFrom} from "rxjs";

@Injectable({
providedIn: 'root'
Expand All @@ -9,16 +10,16 @@ export class MaterialService {
data: any = null;

constructor(private http: HttpClient) {
this.http.get('assets/index.json')
.toPromise().then(json => {
this.data = json;
});
lastValueFrom(this.http.get('assets/index.json'))
.then(json => {
this.data = json;
});
}

public ready(): Promise<any> {
const promise = new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
if (this.data === null) {
this.http.get('assets/index.json').toPromise()
lastValueFrom(this.http.get('assets/index.json'))
.then(json => {
this.data = json;
resolve(this.data);
Expand All @@ -29,6 +30,5 @@ export class MaterialService {
resolve(this.data);
}
});
return promise;
}
}
15 changes: 0 additions & 15 deletions src/app/today/today.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,3 @@ ion-footer {
//color: var(--pink-color);
}
}

@media (min-width: 450px) {
.width-80 {
align-self: center;
width: 80%;
max-width: 600px;
}
}

@media (max-width: 450px) {
.width-80 {
align-self: center;
width: 90%;
}
}
16 changes: 16 additions & 0 deletions src/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,19 @@
@import '~@ionic/angular/css/text-alignment.css';
@import '~@ionic/angular/css/text-transformation.css';
@import '~@ionic/angular/css/flex-utils.css';


@media (min-width: 450px) {
.width-80 {
align-self: center;
width: 80%;
max-width: 600px;
}
}

@media (max-width: 450px) {
.width-80 {
align-self: center;
width: 90%;
}
}

0 comments on commit b9f9cb7

Please sign in to comment.