Skip to content

Commit d7bd63d

Browse files
committed
Remove prefix in ResumePlugin options
1 parent 304eb31 commit d7bd63d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/BookReader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ BookReader.prototype.initParams = function() {
401401
}
402402

403403
// Check for Resume plugin
404-
if (this.options.enablePageResume) {
404+
if (this._plugins.resume?.options.enabled) {
405405
// Check cookies
406406
const val = this._plugins.resume.getResumeValue();
407407
if (val !== null) {

src/plugins/plugin.resume.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ BookReader.docCookies = docCookies;
1212
*/
1313
export class ResumePlugin extends BookReaderPlugin {
1414
options = {
15-
enablePageResume: true,
15+
enabled: true,
1616
/** @type {string|null} eg '/', '/details/id' */
17-
resumeCookiePath: null,
17+
cookiePath: null,
1818
}
1919

2020
/** @override */
2121
init() {
22-
if (this.options.enablePageResume) {
22+
if (this.options.enabled) {
2323
this.br.bind(EVENTS.fragmentChange, () => {
2424
const params = this.br.paramsFromCurrent();
2525
this.updateResumeValue(params.index);
@@ -60,9 +60,9 @@ export class ResumePlugin extends BookReaderPlugin {
6060
*/
6161
updateResumeValue(index, cookieName) {
6262
const ttl = new Date(+new Date + 12096e5); // 2 weeks
63-
// For multiple files in item, leave resumeCookiePath blank
64-
// It's likely we can remove resumeCookiePath using getCookiePath()
65-
const path = this.options.resumeCookiePath
63+
// For multiple files in item, leave cookiePath blank
64+
// It's likely we can remove cookiePath using getCookiePath()
65+
const path = this.options.cookiePath
6666
|| this.getCookiePath(window.location.pathname);
6767
BookReader.docCookies.setItem(cookieName || 'br-resume', index, ttl, path, null, false);
6868
}

tests/jest/BookReader.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test('checks cookie when initParams called', () => {
4747
test('does not check cookie when initParams called', () => {
4848
br._plugins.resume.getResumeValue = jest.fn(() => null);
4949
br.urlReadFragment = jest.fn(() => '');
50-
br.options.enablePageResume = false;
50+
br.options.plugins.resume.enabled = false;
5151

5252
const params = br.initParams();
5353
expect(br._plugins.resume.getResumeValue).toHaveBeenCalledTimes(0);
@@ -59,7 +59,7 @@ test('does not check cookie when initParams called', () => {
5959
test('gets index from fragment when both fragment and cookie when InitParams called', () => {
6060
br._plugins.resume.getResumeValue = jest.fn(() => 15);
6161
br.urlReadFragment = jest.fn(() => 'page/n4');
62-
br.options.enablePageResume = true;
62+
br.options.plugins.resume.enabled = true;
6363

6464
const params = br.initParams();
6565
expect(br._plugins.resume.getResumeValue).toHaveBeenCalledTimes(1);

tests/jest/plugins/plugin.resume.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('updateResumeValue', () => {
3636

3737
test('handles cookieName=null', () => {
3838
const p = new ResumePlugin(null);
39-
p.setup({ resumeCookiePath: '/details/goody' });
39+
p.setup({ cookiePath: '/details/goody' });
4040
const setItemSpy = sinon.spy(docCookies, 'setItem');
4141

4242
p.updateResumeValue(16);
@@ -45,7 +45,7 @@ describe('updateResumeValue', () => {
4545
expect(setItemSpy.args[0][3]).toEqual('/details/goody');
4646
});
4747

48-
test('handles resumeCookiePath not set', () => {
48+
test('handles cookiePath not set', () => {
4949
const setItemSpy = sinon.spy(docCookies, 'setItem');
5050
// Save function
5151
const saveFn = br._plugins.resume.getCookiePath;

0 commit comments

Comments
 (0)