Skip to content

Commit

Permalink
Pass session instance to cache constructor (#1063)
Browse files Browse the repository at this point in the history
We refactored the cache class to not take a session in the constructor
in 485115d.

But after reverting the disk cache #1062
the cache needs a reference to the session again.
  • Loading branch information
Alberto Fernández-Capel committed Nov 14, 2023
1 parent 675d626 commit 0d2ec4b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/cache.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { setMetaContent } from "../util"

export class Cache {
constructor(session) {
this.session = session
}

clear() {
this.session.clearCache()
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Session {
formLinkClickObserver = new FormLinkClickObserver(this, document.documentElement)
frameRedirector = new FrameRedirector(this, document.documentElement)
streamMessageRenderer = new StreamMessageRenderer()
cache = new Cache()
cache = new Cache(this)

drive = true
enabled = true
Expand Down
1 change: 1 addition & 0 deletions src/tests/unit/export_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test("Turbo interface", () => {
assert.equal(typeof Turbo.setConfirmMethod, "function")
assert.equal(typeof Turbo.setFormMode, "function")
assert.equal(typeof Turbo.cache, "object")
assert.equal(typeof Turbo.cache.clear, "function")
assert.equal(typeof Turbo.navigator, "object")
assert.equal(typeof Turbo.session, "object")
})
Expand Down

0 comments on commit 0d2ec4b

Please sign in to comment.