Skip to content

Commit 5bf4a1a

Browse files
committed
fix: Mutate data before caching to disc.
1 parent 83f8091 commit 5bf4a1a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/services/rfcs.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,11 @@ export async function reloadCache() {
8080
https://github.com/github-tools/github/issues/593
8181
https://github.com/github-tools/github/issues/578
8282
*/
83-
const { data } = await repository._requestAllPages(
83+
let { data } = await repository._requestAllPages(
8484
`/repos/${repository.__fullname}/pulls?state=all`
8585
)
8686

87-
if (Array.isArray(data) && data.length) {
88-
await writeFile(PATH_CACHE_FILE, JSON.stringify(data))
89-
}
90-
91-
console.info(`Cached ${data.length} RFCs to disc!`)
92-
93-
rfcs = data.map(rfc => {
87+
data = data.map(rfc => {
9488
/*
9589
WORKAROUND: For some stupid reason, Discord mobile doesn't like CR+LF here.
9690
SEE: https://github.com/Elfayer/vue-land-bot/issues/58
@@ -102,6 +96,14 @@ export async function reloadCache() {
10296
return rfc
10397
})
10498

99+
if (Array.isArray(data) && data.length) {
100+
await writeFile(PATH_CACHE_FILE, JSON.stringify(data))
101+
}
102+
103+
console.info(`Cached ${data.length} RFCs to disc!`)
104+
105+
rfcs = data
106+
105107
return rfcs
106108
} catch (e) {
107109
console.error(e)

0 commit comments

Comments
 (0)