Skip to content

Commit 5a7a5bd

Browse files
committed
fixes #64
1 parent a487576 commit 5a7a5bd

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/app/app.component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, ViewChild, OnDestroy, ElementRef } from '@angular/core';
1+
import { Component, OnInit, ViewChild, AfterViewInit, OnDestroy, ElementRef } from '@angular/core';
22
import { environment } from '../environments/environment';
33
import { CanvasType } from './CanvasType';
44
import { Subscription } from 'rxjs/Subscription';
@@ -9,16 +9,18 @@ import { AnimatorService, CanvasResizeService, HoverStateService, SelectionState
99
import * as $ from 'jquery';
1010
import * as erd from 'element-resize-detector';
1111
import * as _ from 'lodash';
12+
import { MdSnackBar, MdSnackBarConfig } from '@angular/material';
1213

1314
const IS_DEV_MODE = !environment.production;
1415
const 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

Comments
 (0)