1- import { Component , OnInit , ViewChild , OnDestroy , ElementRef } from '@angular/core' ;
1+ import { Component , OnInit , ViewChild , AfterViewInit , OnDestroy , ElementRef } from '@angular/core' ;
22import { environment } from '../environments/environment' ;
33import { CanvasType } from './CanvasType' ;
44import { Subscription } from 'rxjs/Subscription' ;
@@ -9,16 +9,18 @@ import { AnimatorService, CanvasResizeService, HoverStateService, SelectionState
99import * as $ from 'jquery' ;
1010import * as erd from 'element-resize-detector' ;
1111import * as _ from 'lodash' ;
12+ import { MdSnackBar , MdSnackBarConfig } from '@angular/material' ;
1213
1314const IS_DEV_MODE = ! environment . production ;
1415const ELEMENT_RESIZE_DETECTOR = erd ( ) ;
16+ const STORAGE_KEY_FIRST_TIME_USER = 'storage_key_first_time_user' ;
1517
1618@Component ( {
1719 selector : 'app-root' ,
1820 templateUrl : './app.component.html' ,
1921 styleUrls : [ './app.component.scss' ]
2022} )
21- export class AppComponent implements OnInit , OnDestroy {
23+ export class AppComponent implements OnInit , AfterViewInit , OnDestroy {
2224
2325 // TODO: need to warn user about svgs not being structurally identical somehow...
2426 // TODO: or give the user a way to update the incorrect path id names or something...?
@@ -40,6 +42,7 @@ export class AppComponent implements OnInit, OnDestroy {
4042 @ViewChild ( 'canvasContainer' ) private canvasContainerRef : ElementRef ;
4143
4244 constructor (
45+ private readonly snackBar : MdSnackBar ,
4346 private readonly layerStateService : LayerStateService ,
4447 private readonly hoverStateService : HoverStateService ,
4548 private readonly selectionStateService : SelectionStateService ,
@@ -127,6 +130,16 @@ export class AppComponent implements OnInit, OnDestroy {
127130 } ) ;
128131 }
129132
133+ ngAfterViewInit ( ) {
134+ const isFirstTimeUser = window . localStorage . getItem ( STORAGE_KEY_FIRST_TIME_USER ) ;
135+ if ( ! isFirstTimeUser ) {
136+ window . localStorage . setItem ( STORAGE_KEY_FIRST_TIME_USER , 'true' ) ;
137+ setTimeout ( ( ) => {
138+ this . snackBar . open ( 'Ready to work offline' , 'Dismiss' , { duration : 5000 } ) ;
139+ } ) ;
140+ }
141+ }
142+
130143 ngOnDestroy ( ) {
131144 ELEMENT_RESIZE_DETECTOR . removeAllListeners ( this . canvasContainer . get ( 0 ) ) ;
132145 this . subscriptions . forEach ( s => s . unsubscribe ( ) ) ;
@@ -206,7 +219,7 @@ export class AppComponent implements OnInit, OnDestroy {
206219 const activePathLayer = this . layerStateService . getActivePathLayer ( canvasType ) ;
207220 const unsplitOpsMap : Map < number , Array < { subIdx : number , cmdIdx : number } > > = new Map ( ) ;
208221 for ( const selection of selections ) {
209- const { subIdx, cmdIdx} = selection . commandId ;
222+ const { subIdx, cmdIdx } = selection . commandId ;
210223 if ( ! activePathLayer . pathData . getSubPaths ( ) [ subIdx ] . getCommands ( ) [ cmdIdx ] . isSplit ) {
211224 continue ;
212225 }
0 commit comments