Skip to content

Commit

Permalink
fix(ui): tutorial, when skipped at first step, resumes on navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
feugy committed Sep 29, 2020
1 parent 4453f88 commit 7751858
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
17 changes: 7 additions & 10 deletions README.md
Expand Up @@ -12,24 +12,22 @@ There are thunsands of them in the wild. This mine is an excuse for learning [El

### features

- [ ] system integration (play folder/file)
- [ ] images from tags
- [ ] artists' albums
- [ ] smaller screen support (UI refactor)
- [ ] enqueue tracks/albums by dragging to tracks queue
- [ ] add to playlist from Album details/Playlist details/Search results pages
- [ ] configure replay gain from settings
- [ ] configurable simple/double click behaviour
- [ ] configurable "play now" behaviour: either clear & add, or enqueue and jump
- [ ] display years (artist & album details page)
- [ ] add to playlist from Album details/Playlist details/Search results pages
- [ ] enqueue tracks/albums by dragging to tracks queue
- [ ] system integration (play folder/file)
- [ ] images from tags
- [ ] display album/artist descriptions
- [ ] number of disk on album details page
- [ ] display years (artist & album details page)
- [ ] configure replay gain from settings
- [ ] display tracks/albums/artists count in settings
- [ ] allow reseting database from settings
- [ ] smaller screen support (UI refactor)

### tools

- [x] Automated release process with github action
- [ ] App automated end to end tests
- [ ] Code coverage follow-up (https://app.codacy.com/login/https://codeclimate.com/dashboard)
- [ ] more technical documentation (install & release process notably)
Expand Down Expand Up @@ -57,7 +55,6 @@ There are thunsands of them in the wild. This mine is an excuse for learning [El

1. startup performance isn't great
1. now that I'm not using FLIP animations, native drag'n drop may be leaner than my mouse-event based implementation
1. When DB has albums and playlists, tutorial enters infinite loop
1. Undetected live changes: remove tracks and re-add them. This is a linux-only issue with chokidar
- https://github.com/paulmillr/chokidar/issues/917
- https://github.com/paulmillr/chokidar/issues/591
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -18,7 +18,7 @@
"dev": "rollup -c -w",
"postinstall": "electron-builder install-app-deps",
"release:artifacts": "electron-builder",
"release:bump": "standard-version -prerelease alpha",
"release:bump": "standard-version -s -prerelease alpha",
"release:publish": "electron-builder -p onTagOrDraft",
"start": "electron .",
"storybook": "start-storybook -p 6006 -s ./fixtures",
Expand Down Expand Up @@ -125,4 +125,4 @@
"node scripts/remove-secrets"
]
}
}
}
22 changes: 16 additions & 6 deletions renderer/stores/tutorial.js
Expand Up @@ -76,20 +76,29 @@ const current$ = new BehaviorSubject(null)

const clickNextButton$ = new Subject()

let subscription = null

function awaitsEvent(store, criteria = () => true) {
const subscription = store.subscribe(async value => {
subscription = store.subscribe(async value => {
if (criteria(value)) {
await tick()
if (typeof subscription === 'function') {
subscription()
} else {
subscription.unsubscribe()
}
unsubscribe()
next()
}
})
}

function unsubscribe() {
if (subscription) {
if (typeof subscription === 'function') {
subscription()
} else {
subscription.unsubscribe()
}
subscription = null
}
}

function next() {
const idx = steps.indexOf(current$.value)
if (idx === -1 || idx < steps.length - 1) {
Expand All @@ -113,6 +122,7 @@ export async function start() {
}

export async function stop() {
unsubscribe()
if (current$.value !== null) {
current$.next(null)
allowNavigation()
Expand Down
15 changes: 12 additions & 3 deletions renderer/stores/tutorial.test.js
Expand Up @@ -150,14 +150,23 @@ describe('tutorial store', () => {
it('can be started and stopped', async () => {
start()
await sleep()

handleNextButtonClick()
await sleep()

expect(get(current)).toEqual(
expect.objectContaining({
anchorId: 'locale',
messageKey: 'tutorial.chooseLocale',
nextButtonKey: 'alright'
anchorId: 'folder',
messageKey: 'tutorial.findMusic'
})
)

stop()
// make sure tutorial is not awaiting
push('/album')
await sleep(10)

expect(get(current)).toEqual(null)
expect(location.hash).toEqual('#/album')
})
})

0 comments on commit 7751858

Please sign in to comment.