Skip to content

Commit

Permalink
Merge pull request #2077 from intersective/prerelease
Browse files Browse the repository at this point in the history
Hotfix 2.3.0.5
  • Loading branch information
shawnm0705 authored Feb 2, 2024
2 parents 0ffa368 + 912fe4b commit 2a4fe68
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ export class ActivityComponent implements OnInit, OnChanges {
if (!task.dueDate) {
return '';
}
// overdue shows the label only
if (task.isOverdue) {
return '';
}

return `<strong>Due Date</strong>: ${ this.utils.utcToLocal(task.dueDate) }`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</ion-chip>

<p class="assessment subtitle-1 due-date" *ngIf="assessment.dueDate" style="margin: 10px 0;">
<strong i18n>Due Date</strong>: {{ assessment.dueDate | date : 'd MMMM y' }}
<strong i18n>Due Date</strong>: {{ utils.utcToLocal(assessment.dueDate, 'timeZone') }}
</p>

<ion-text class="ion-text-left">
Expand Down
23 changes: 16 additions & 7 deletions projects/v3/src/app/services/pusher.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Injectable, Optional, NgZone } from '@angular/core';
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { RequestService } from 'request';
import { environment } from '@v3/environments/environment';
import { UtilsService } from '@v3/services/utils.service';
import { BrowserStorageService } from '@v3/services/storage.service';
import { PusherStatic, Channel } from 'pusher-js';
import * as Pusher from 'pusher-js';
import Pusher, { Channel } from 'pusher-js';
import { ApolloService } from './apollo.service';

const api = {
Expand Down Expand Up @@ -53,7 +52,6 @@ export class PusherService {
private request: RequestService,
private utils: UtilsService,
public storage: BrowserStorageService,
private ngZone: NgZone,
private apolloService: ApolloService,
) {
this.pusherKey = environment.pusherKey;
Expand Down Expand Up @@ -145,15 +143,19 @@ export class PusherService {
};
const newPusherInstance = new Pusher(this.pusherKey, config)
.bind('pusher:connection_established', () => {
// eslint-disable-next-line no-console
console.log('pusher:connection_established');
})
.bind('pusher:connection_disconnected', () => {
// eslint-disable-next-line no-console
console.log('pusher:connection_disconnected');
})
.bind('pusher:connection_failed', () => {
// eslint-disable-next-line no-console
console.log('pusher:connection_failed');
})
.bind('pusher:error', (err) => {
// eslint-disable-next-line no-console
console.log('pusher:error', err);
});
return newPusherInstance;
Expand All @@ -167,8 +169,8 @@ export class PusherService {
* true: subscribed
* false: haven't subscribed
*/
isSubscribed(channelName): boolean {
return !!this.pusher.allChannels().find((channel: Channel) => channel.name === channelName && channel.subscribed);
isSubscribed(channelName: string): boolean {
return this.pusher.allChannels().some((channel: Channel) => channel.name === channelName && channel.subscribed);
}

/**
Expand Down Expand Up @@ -255,8 +257,14 @@ export class PusherService {
if (this.isSubscribed(channelName)) {
return;
}

switch (type) {
case 'notification':
// unsubscribe previous channel
if (this.channels.notification) {
this.channels.notification.subscription.unbind_all();
}

this.channels.notification = {
name: channelName,
subscription: this.pusher.subscribe(channelName)
Expand All @@ -276,9 +284,10 @@ export class PusherService {
console.error(`fail to subscribe ${channelName}::`, data);
});
break;

case 'chat':
// don't need to subscribe again if already subscribed
if (this.channels.chat.find(c => c.name === channelName)) {
if (this.channels.chat.some(c => c.name === channelName)) {
return;
}
const channel = {
Expand Down
12 changes: 9 additions & 3 deletions projects/v3/src/app/services/utils.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,26 @@ export class UtilsService {
const date = new Date(this.iso8601Formatter(time));

const currentLocale = this.getCurrentLocale();
const formattedTime = new Intl.DateTimeFormat(currentLocale, {
const timeFormat: Intl.DateTimeFormatOptions = {
hour12: this.isHour12Format(currentLocale),
hour: 'numeric',
minute: 'numeric'
}).format(date);
};

switch (display) {
case 'date':
return this.dateFormatter(date);

case 'time':
return formattedTime;
return new Intl.DateTimeFormat(currentLocale, timeFormat).format(date);

case 'timeZone':
const formatted = new Intl.DateTimeFormat(currentLocale, timeFormat);
const resolvedOptions = formatted.resolvedOptions();
return `${this.dateFormatter(date)} ${formatted.format(date)} (${resolvedOptions.timeZone})`;

default:
const formattedTime = new Intl.DateTimeFormat(currentLocale, timeFormat).format(date);
return this.dateFormatter(date) + ' ' + formattedTime;
}
}
Expand Down

0 comments on commit 2a4fe68

Please sign in to comment.