clean up
This commit is contained in:
parent
7cb5b3f226
commit
24be608434
|
@ -40,7 +40,6 @@ import { ThreadComponent } from './components/stream/thread/thread.component';
|
|||
import { HashtagComponent } from './components/stream/hashtag/hashtag.component';
|
||||
import { StreamOverlayComponent } from './components/stream/stream-overlay/stream-overlay.component';
|
||||
import { DatabindedTextComponent } from './components/stream/status/databinded-text/databinded-text.component';
|
||||
import { MastodonTimePipe } from './pipes/mastodon-time.pipe';
|
||||
import { TimeAgoPipe } from './pipes/time-ago.pipe';
|
||||
|
||||
const routes: Routes = [
|
||||
|
@ -75,7 +74,6 @@ const routes: Routes = [
|
|||
HashtagComponent,
|
||||
StreamOverlayComponent,
|
||||
DatabindedTextComponent,
|
||||
MastodonTimePipe,
|
||||
TimeAgoPipe
|
||||
],
|
||||
imports: [
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
import { MastodonTimePipe } from './mastodon-time.pipe';
|
||||
|
||||
xdescribe('MastodonTimePipe', () => {
|
||||
// it('create an instance', () => {
|
||||
// const pipe = new MastodonTimePipe();
|
||||
// expect(pipe).toBeTruthy();
|
||||
// });
|
||||
});
|
|
@ -1,48 +0,0 @@
|
|||
import { Pipe, PipeTransform, Inject, LOCALE_ID } from '@angular/core';
|
||||
import { formatDate } from '@angular/common';
|
||||
|
||||
@Pipe({
|
||||
name: 'mastodontime',
|
||||
pure: false
|
||||
})
|
||||
export class MastodonTimePipe implements PipeTransform {
|
||||
|
||||
constructor(@Inject(LOCALE_ID) private locale: string) { }
|
||||
|
||||
// private cachedDict: { [id:string] : string } = {};
|
||||
// private cached: string;
|
||||
// private resultCached: string;
|
||||
|
||||
transform(value: string): string {
|
||||
// if (value == this.cached && this.resultCached) {
|
||||
// return this.resultCached;
|
||||
// }
|
||||
|
||||
// if(this.cachedDict[value]) {
|
||||
// return this.cachedDict[value];
|
||||
// }
|
||||
|
||||
const date = (new Date(value)).getTime();
|
||||
const now = Date.now();
|
||||
const timeDelta = (now - date) / (1000);
|
||||
|
||||
if (timeDelta < 60) {
|
||||
return `${timeDelta | 0}s`;
|
||||
} else if (timeDelta < 60 * 60) {
|
||||
return `${timeDelta / 60 | 0}m`;
|
||||
} else if (timeDelta < 60 * 60 * 24) {
|
||||
return `${timeDelta / (60 * 60) | 0}h`;
|
||||
} else if (timeDelta < 60 * 60 * 24 * 31) {
|
||||
return `${timeDelta / (60 * 60 * 24) | 0}d`;
|
||||
}
|
||||
|
||||
return formatDate(date, 'MM/dd', this.locale);
|
||||
|
||||
// this.cachedDict[value] = formatDate(date, 'MM/dd', this.locale);
|
||||
|
||||
// // this.cached = value;
|
||||
// // this.resultCached = formatDate(date, 'MM/dd', this.locale);
|
||||
|
||||
// return this.cachedDict[value];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue