-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Perpetual Edit #1915
Draft
Soxasora
wants to merge
13
commits into
stackernews:master
Choose a base branch
from
Soxasora:perpetual_edit
base: master
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
Perpetual Edit #1915
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
db1838b
OldItem trigger, item history; Shadow edits; items can always be edit…
Soxasora 7e6e08f
edits to OldItem; comments should be edited in place; also delete Old…
Soxasora 6d9ca69
Early history UI
Soxasora 3fe1ecd
OldItem modal, re-implement imgproxyUrls, fix typos
Soxasora 5ae815e
restore missing columns, fix timestamp issues with Item History
Soxasora 4a528bd
adjust shadow edit countdown and references, scrollable item history
Soxasora b689eac
ItemHistory refactor
Soxasora d8aa1ea
fix typeDefs and fragments, better naming, decluttering
Soxasora 0a6bcb6
fix lint
Soxasora f219eba
Prisma-handled history; prevent history also on jobs and special items
Soxasora db45916
cleanup; add comments
Soxasora 7500a2f
adjust timestamps, fetch OldItem by id, less expensive oldVersions
Soxasora cb2b692
enhance: faster history retrieving
Soxasora 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { timeSince } from '@/lib/time' | ||
import styles from './item.module.css' | ||
import Text from './text' | ||
import { Dropdown } from 'react-bootstrap' | ||
import { useShowModal } from './modal' | ||
|
||
// OldItem: takes a version and shows the old item | ||
export function OldItem ({ version }) { | ||
return ( | ||
<> | ||
<div className={styles.other}> | ||
{!version.cloneBornAt ? 'created' : 'edited'} {timeSince(new Date(version.cloneBornAt || version.createdAt))} ago | ||
</div> | ||
<div> | ||
<h5>{version.title}</h5> | ||
<Text itemId={version.originalItemId} topLevel imgproxyUrls={version.imgproxyUrls}>{version.text}</Text> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
// History dropdown: takes an item and by mapping over the oldVersions, it will show the history of the item | ||
export default function HistoryDropdown ({ item }) { | ||
const showModal = useShowModal() | ||
|
||
return ( | ||
<Dropdown className='pointer' as='span'> | ||
<Dropdown.Toggle as='span' onPointerDown={e => e.preventDefault()}> | ||
edited | ||
</Dropdown.Toggle> | ||
<Dropdown.Menu style={{ maxHeight: '15rem', overflowY: 'auto' }}> | ||
<Dropdown.Header className='text-muted'> | ||
edited {item.oldVersions.length} times | ||
</Dropdown.Header> | ||
<hr className='dropdown-divider' /> | ||
<Dropdown.Item title={item.oldVersions[0].cloneDiedAt}> | ||
edited {timeSince(new Date(item.oldVersions[0].cloneDiedAt))} ago (most recent) | ||
</Dropdown.Item> | ||
{item.oldVersions.map((version) => ( | ||
<Dropdown.Item | ||
key={version.id} | ||
title={version.cloneBornAt || version.createdAt} | ||
onClick={() => showModal((onClose) => <OldItem version={version} />)} | ||
> | ||
{!version.cloneBornAt ? 'created' : 'edited'} {timeSince(new Date(version.cloneBornAt || version.createdAt))} ago | ||
</Dropdown.Item> | ||
))} | ||
</Dropdown.Menu> | ||
</Dropdown> | ||
) | ||
} |
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
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.
Since we really just want to track Item content editing, I switched to a Prisma-based version of the trigger that I think it's more appropriate. Before, every update to Item could fire the
procedure
and confront the conditions.Also on this, not having Item inheritance made me think that having just enough columns can be okay, but also having the whole item is okay to me, maybe future-proof