-
Notifications
You must be signed in to change notification settings - Fork 48
feat: add calendar notes directory preference #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
colebemis
wants to merge
14
commits into
main
Choose a base branch
from
calendar-notes-directory
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a328349
feat: add calendar notes directory preference
41e1b24
Fix: Note IDs are now full filepath without .md
517510f
Update navigation and link rendering for calendar notes directory
ba9f9d2
Fix isDailyNote/isWeeklyNote checks for new note ID format
4ab25e2
Fix date autocomplete to use calendar notes directory
3b083e6
fix: extract basename before formatting week/date strings
9889f7c
Fix VITE_GITHUB_PAT token not persisting across reloads
c341bcf
Fix: Use basename for calendar note ID comparisons
7aac865
fix: calendar notes directory scope and navigation
189cd89
Fix note preview and parse-note to respect calendar notes directory c…
38d6ddf
fix: require correct directory prefix for note type detection
2090342
refactor: use note.type as single source of truth for calendar note d…
adb5ad9
fix: format code with prettier (line length)
168de3b
refactor: rename calendarNotesDirectory to calendarNotesDir
colebemis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { useAtomValue, useSetAtom } from "jotai" | ||
| import React from "react" | ||
| import { | ||
| calendarNotesDirectoryAtom, | ||
| configAtom, | ||
| globalStateMachineAtom, | ||
| isRepoClonedAtom, | ||
| loadConfigAtom, | ||
| setConfigAtom, | ||
| } from "../global-state" | ||
| import { Config, CONFIG_FILE_PATH, normalizeDirectoryPath, serializeConfig } from "../utils/config" | ||
|
|
||
| export function useConfig() { | ||
| return useAtomValue(configAtom) | ||
| } | ||
|
|
||
| export function useCalendarNotesDirectory() { | ||
| return useAtomValue(calendarNotesDirectoryAtom) | ||
| } | ||
|
|
||
| /** Load config from filesystem when repo is cloned */ | ||
| export function useLoadConfigOnMount() { | ||
| const isRepoCloned = useAtomValue(isRepoClonedAtom) | ||
| const loadConfig = useSetAtom(loadConfigAtom) | ||
| const hasLoadedRef = React.useRef(false) | ||
|
|
||
| React.useEffect(() => { | ||
| if (isRepoCloned && !hasLoadedRef.current) { | ||
| hasLoadedRef.current = true | ||
| loadConfig() | ||
| } | ||
| }, [isRepoCloned, loadConfig]) | ||
| } | ||
|
|
||
| export function useSaveConfig() { | ||
| const send = useSetAtom(globalStateMachineAtom) | ||
| const setConfig = useSetAtom(setConfigAtom) | ||
|
|
||
| return React.useCallback( | ||
| (config: Config) => { | ||
| // Normalize the config before saving | ||
| const normalizedConfig: Config = { | ||
| ...config, | ||
| calendarNotesDirectory: normalizeDirectoryPath(config.calendarNotesDirectory) || undefined, | ||
| } | ||
|
|
||
| // Update the config atom (and localStorage) | ||
| setConfig(normalizedConfig) | ||
|
|
||
| // Write the config file to the repo | ||
| send({ | ||
| type: "WRITE_FILES", | ||
| markdownFiles: { [CONFIG_FILE_PATH]: serializeConfig(normalizedConfig) }, | ||
| commitMessage: "Update Lumen config", | ||
| }) | ||
| }, | ||
| [send, setConfig], | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This key should be repo specific because eventually we might want to have multiple repos cloned at once