Skip to content

Commit

Permalink
Web: Show alert if server connection fails
Browse files Browse the repository at this point in the history
Issue #17
  • Loading branch information
xuhcc committed Jun 21, 2022
1 parent 176a9d7 commit 858f506
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Mobile, Web: Added support for yearly tasks.
- Web: Showing alert if server connection fails.

## 1.6.1

Expand Down
2 changes: 1 addition & 1 deletion src/app/plaintext/plaintext.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ViewContainerRef, AfterViewInit, ViewChild, ElementRef } from '@angular/core'
import { Component, ViewContainerRef, ViewChild, ElementRef } from '@angular/core'

import { SideDrawerService } from '../nav/sidedrawer.service'
import { RouterService } from '../shared/router.service'
Expand Down
2 changes: 1 addition & 1 deletion src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class SettingsComponent implements OnInit {
}
}).catch((error) => {
console.warn(error)
showToast(error.toString())
showToast(error.toString(), true)
})
}

Expand Down
6 changes: 4 additions & 2 deletions src/app/shared/helpers/toast.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function showToast(text: string) {
console.log(text)
export function showToast(text: string, isError: boolean) {
if (isError) {
alert(text)
}
}
6 changes: 3 additions & 3 deletions src/app/shared/todo-file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class TodoFileService implements OnDestroy {
this.router.navigate(['/settings'])
}
console.error(error)
showToast(error.toString())
showToast(error.toString(), true)
return
}
if (watch && this.content && this.content === content) {
Expand All @@ -148,7 +148,7 @@ export class TodoFileService implements OnDestroy {
this.todoItems = TodoTxt.parse(this.content, getExtensions())
}
this.fileChanged.next(true) // true = IDs are probably changed
showToast('File loaded')
showToast('File loaded', false)
}

private async save(): Promise<void> {
Expand All @@ -157,7 +157,7 @@ export class TodoFileService implements OnDestroy {
await this.file.write(this.settings.path, this.content)
} catch (error) {
console.error(error)
showToast(error.toString())
showToast(error.toString(), true)
return
}
this.fileChanged.next(false) // false => IDs are not changed
Expand Down
2 changes: 1 addition & 1 deletion src/app/welcome/welcome.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class WelcomeComponent implements OnInit {
}
}).catch((error) => {
console.warn(error)
showToast(error.toString())
showToast(error.toString(), true)
})
}

Expand Down

0 comments on commit 858f506

Please sign in to comment.