Skip to content

Commit a07deff

Browse files
committedNov 16, 2023
Clean up
1 parent 9f07762 commit a07deff

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
 

‎src/global-state.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ function createGlobalStateMachine() {
7979
markdownFiles: Record<string, string>
8080
}
8181
}
82-
writeFile: { data: void }
83-
deleteFile: { data: void }
82+
writeFile: {
83+
data: void
84+
}
85+
deleteFile: {
86+
data: void
87+
}
8488
}
8589
},
8690
predictableActionArguments: true,
@@ -103,7 +107,7 @@ function createGlobalStateMachine() {
103107
},
104108
},
105109
signedOut: {
106-
entry: "clearGitHubUser",
110+
entry: ["clearGitHubUser", "clearGitHubUserLocalStorage"],
107111
on: {
108112
SIGN_IN: {
109113
target: "signedIn",
@@ -275,6 +279,7 @@ function createGlobalStateMachine() {
275279
}
276280

277281
const githubRepo = { owner, name }
282+
278283
const markdownFiles =
279284
getMarkdownFilesFromLocalStorage() ?? (await getMarkdownFilesFromFs(ROOT_DIR))
280285

@@ -455,6 +460,9 @@ function createGlobalStateMachine() {
455460
clearGitHubUser: assign({
456461
githubUser: null,
457462
}),
463+
clearGitHubUserLocalStorage: () => {
464+
localStorage.removeItem(GITHUB_USER_KEY)
465+
},
458466
setGitHubRepo: assign({
459467
githubRepo: (_, event) => {
460468
switch (event.type) {
@@ -503,6 +511,7 @@ function createGlobalStateMachine() {
503511
)
504512
}
505513

514+
/** Retrieve cached markdown files from local storage */
506515
function getMarkdownFilesFromLocalStorage() {
507516
const markdownFiles = JSON.parse(localStorage.getItem(MARKDOWN_FILES_KEY) ?? "null")
508517
if (!markdownFiles) return null

‎src/global-state.typegen.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
};
3333
eventsCausingActions: {
3434
"clearGitHubUser": "SIGN_OUT" | "error.platform.global.resolvingUser:invocation[0]";
35+
"clearGitHubUserLocalStorage": "SIGN_OUT" | "error.platform.global.resolvingUser:invocation[0]";
3536
"deleteMarkdownFile": "DELETE_FILE";
3637
"deleteMarkdownFileLocalStorage": "DELETE_FILE";
3738
"setError": "error.platform.global.signedIn.cloned.change.deletingFile:invocation[0]" | "error.platform.global.signedIn.cloned.change.writingFile:invocation[0]" | "error.platform.global.signedIn.cloned.sync.syncing:invocation[0]" | "error.platform.global.signedIn.cloningRepo:invocation[0]" | "error.platform.global.signedIn.resolvingRepo:invocation[0]";

0 commit comments

Comments
 (0)