-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #542 from YuRiJinX/boorkmark
feat: support bookmark
- Loading branch information
Showing
6 changed files
with
78 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import syncStorage from '@/helpers/syncStorage'; | ||
|
||
function resolveBookmarks(files, bookmarks) { | ||
const data = syncStorage.getSync('bookmark'); | ||
const temp = {}; | ||
files.forEach((file, i) => { | ||
temp[file] = bookmarks[i]; | ||
}); | ||
syncStorage.setSync('bookmark', { ...data, ...temp }); | ||
} | ||
|
||
export default { | ||
resolveBookmarks, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import bookmark from '@/helpers/bookmark'; | ||
import syncStorage from '@/helpers/syncStorage'; | ||
|
||
describe.only('bookmark', () => { | ||
const data = { | ||
'/path/1/2/4': 'bookmark1', | ||
'/path/1/3/2': 'bookmark2', | ||
}; | ||
beforeEach(() => { | ||
syncStorage.setSync('bookmark', data); | ||
}); | ||
it('resolveBookmarks', () => { | ||
const files = ['/path/1/2/3/4.mp4']; | ||
const bookmarks = ['bookmark3']; | ||
bookmark.resolveBookmarks(files, bookmarks); | ||
|
||
const data = syncStorage.getSync('bookmark'); | ||
expect(data).deep.equal({ | ||
'/path/1/2/4': 'bookmark1', | ||
'/path/1/3/2': 'bookmark2', | ||
'/path/1/2/3/4.mp4': 'bookmark3', | ||
}); | ||
}); | ||
// it('resolveBookmarks can replace the child files', () => { | ||
// const files = ['/path/1/2']; | ||
// const bookmarks = ['bookmark4']; | ||
// bookmark.resolveBookmarks(files, bookmarks); | ||
|
||
// const data = syncStorage.getSync('bookmark'); | ||
// expect(data).deep.equal({ | ||
// '/path/1/2': 'bookmark4', | ||
// '/path/1/3/2': 'bookmark2', | ||
// }); | ||
// }); | ||
}); |