Skip to content

Commit

Permalink
fix: Cannot read property of null when opening the command palette wi…
Browse files Browse the repository at this point in the history
…thout file
  • Loading branch information
Mara-Li committed Feb 13, 2023
1 parent eb9f2c2 commit 5b3d4a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions plugin/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ export default class GithubPublisher extends Plugin {
name: commands("shareActiveFile") as string,
hotkeys: [],
checkCallback: (checking) => {
const frontmatter = this.app.metadataCache.getFileCache(this.app.workspace.getActiveFile()).frontmatter;
const file = this.app.workspace.getActiveFile();
const frontmatter = file ? this.app.metadataCache.getFileCache(file).frontmatter : null;
if (
isShared(frontmatter, this.settings, file)
file && frontmatter && isShared(frontmatter, this.settings, file)
) {
if (!checking) {
shareOneNote(
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/data_validation_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export function isInternalShared(
*/

export function isShared(
meta: FrontMatterCache,
meta: FrontMatterCache | null,
settings: GitHubPublisherSettings,
file: TFile
): boolean {
if (!file || file.extension !== "md") {
if (!file || file.extension !== "md" || meta === null) {
return false;
}
const folderList = settings.plugin.excludedFolder;
Expand Down

0 comments on commit 5b3d4a4

Please sign in to comment.