-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71bb057
commit 4d17d34
Showing
13 changed files
with
123 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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 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
6 changes: 6 additions & 0 deletions
6
code/client/src/ui/pages/document/components/commit-history/CommitHistory.scss
This file contains 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 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
2 changes: 2 additions & 0 deletions
2
code/client/src/ui/pages/document/components/commit/Commit.scss
This file contains 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,2 @@ | ||
.commit { | ||
} |
46 changes: 46 additions & 0 deletions
46
code/client/src/ui/pages/document/components/commit/Commit.tsx
This file contains 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,46 @@ | ||
import useCommitsService from '@services/commits/useCommitsService'; | ||
import { useEffect, useState } from 'react'; | ||
import { Link, useParams } from 'react-router-dom'; | ||
import { type Commit, CommitData } from '@notespace/shared/src/document/types/commits'; | ||
import useLoading from '@ui/hooks/useLoading'; | ||
import { formatTimePassed } from '@/utils/utils'; | ||
import useFugue from '@domain/editor/fugue/useFugue'; | ||
|
||
function Commit() { | ||
const { loading, startLoading, stopLoading, spinner } = useLoading(); | ||
const [commit, setCommit] = useState<CommitData>(); | ||
const { getCommit } = useCommitsService(); | ||
const { commitId } = useParams(); | ||
const fugue = useFugue(); | ||
|
||
useEffect(() => { | ||
async function fetchCommit() { | ||
const commit = await getCommit(commitId!); | ||
console.log(commit); | ||
setCommit(commit); | ||
fugue.applyOperations(commit.content, true); | ||
stopLoading(); | ||
} | ||
startLoading(); | ||
fetchCommit(); | ||
}, [commitId, getCommit, startLoading, stopLoading]); | ||
|
||
return ( | ||
<div className="commit-revision"> | ||
{loading ? ( | ||
spinner | ||
) : ( | ||
<> | ||
<h2>Commit</h2> | ||
<p> | ||
Committed by <Link to={`/profile/${commit!.author.id}`}>{commit!.author.name}</Link> | ||
{formatTimePassed(new Date(commit!.timestamp).toLocaleString())} | ||
</p> | ||
<pre>{fugue.toString()}</pre> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default Commit; |
This file contains 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 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 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 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 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 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