Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 5274fd7

Browse files
Use SSR safe local storage shim
1 parent d0f0321 commit 5274fd7

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/components/DownloadButton.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<script>
5757
import filesize from 'filesize'
5858
import axios from 'axios'
59+
import local from '~/utils/local'
5960
6061
const LS_DOWNLOAD_FORMAT_EXTENSION_KEY = 'openverse:download-format-extension'
6162
@@ -73,7 +74,7 @@ export default {
7374
},
7475
data() {
7576
const savedFormatExtension =
76-
localStorage.getItem(LS_DOWNLOAD_FORMAT_EXTENSION_KEY) ?? null
77+
local.get(LS_DOWNLOAD_FORMAT_EXTENSION_KEY) ?? null
7778
let format = this.formats[0]
7879
if (savedFormatExtension) {
7980
const found = this.formats.find(
@@ -114,10 +115,7 @@ export default {
114115
return filesize(size, { locale: this.$i18n.locale })
115116
},
116117
setSelectedFormat(format) {
117-
localStorage.setItem(
118-
LS_DOWNLOAD_FORMAT_EXTENSION_KEY,
119-
format.extension_name
120-
)
118+
local.set(LS_DOWNLOAD_FORMAT_EXTENSION_KEY, format.extension_name)
121119
this.selectedFormat = format
122120
},
123121
},

0 commit comments

Comments
 (0)