Skip to content
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

Revert "reverse virtuallist refactor" #5255

Closed
wants to merge 34 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5f6af38
add google photos frontend
mifi Mar 19, 2024
62312be
implement google photos
mifi Apr 8, 2024
f27b1f1
merge main
mifi Apr 8, 2024
6d94531
Merge branch 'main' into google-photos
mifi Apr 12, 2024
bf2a494
separate virtualList from loadAllFiles
mifi Apr 12, 2024
11dfff4
convert virtuallist to TS
mifi Apr 12, 2024
17d3e91
add missing file
mifi Apr 12, 2024
759ee74
Merge branch 'main' of https://github.com/transloadit/uppy
aduh95 Apr 16, 2024
702ed84
document google photos
mifi Apr 12, 2024
ca78a48
lint
aduh95 Apr 16, 2024
94f294e
prettier
mifi Apr 22, 2024
63fdbd7
Merge branch 'main' into google-photos
mifi Apr 22, 2024
339e835
Merge branch 'main' into google-photos
mifi Apr 29, 2024
67f6d0d
merge main
mifi May 5, 2024
701f2eb
run format
mifi May 5, 2024
fdc1662
fix lint
mifi May 5, 2024
d0763f1
implement user info
mifi May 5, 2024
aa09ad0
Merge branch 'main' into google-photos
mifi May 8, 2024
f65edd7
fix tests
mifi May 8, 2024
7792dcc
fix codesandbox
mifi May 9, 2024
345383e
remove accidental js file
mifi May 9, 2024
e8429f7
fix test
mifi May 9, 2024
cf2025d
fix ts
mifi May 9, 2024
0dba1bb
fix ts
mifi May 9, 2024
0c21a5e
fix ts
mifi May 9, 2024
08beacc
don't use inheritance
mifi May 13, 2024
371a7e2
remove GooglePhotosProviderViews
mifi May 13, 2024
03b1d95
git merge main
mifi Jun 12, 2024
503203b
use folder icon for albums
mifi Jun 12, 2024
eb18350
fix test
mifi Jun 12, 2024
b19ae3a
add unnamed
mifi Jun 13, 2024
4983475
Apply suggestions from code review
mifi Jun 13, 2024
5d331b9
reverse virtuallist refactor
mifi Jun 17, 2024
4f7e7d9
Revert "reverse virtuallist refactor"
mifi Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reverse virtuallist refactor
mifi committed Jun 17, 2024

Verified

This commit was signed with the committer’s verified signature.
mifi Mikael Finstad
commit 5d331b9209802a78fdb7fe7e20d2be89597d246f
2 changes: 2 additions & 0 deletions packages/@uppy/dashboard/src/components/FileList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { h } from 'preact'
import { useMemo } from 'preact/hooks'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore untyped
import VirtualList from '@uppy/utils/lib/VirtualList'
import FileItem from './FileItem/index.tsx'

Original file line number Diff line number Diff line change
@@ -26,8 +26,7 @@
* - Tweaked styles for Uppy's Dashboard use case
*/

import { h, Component } from 'preact'
import type { HTMLAttributes } from 'preact/compat'
import { h, Component } from 'preact'

const STYLE_INNER = {
position: 'relative',
@@ -52,21 +51,8 @@ const STYLE_CONTENT = {
overflow: 'visible',
}

type Props<T> = Omit<HTMLAttributes<HTMLDivElement>, 'data'> & {
data: T[]
rowHeight: number
renderRow: (item: T) => h.JSX.Element
// eslint-disable-next-line react/require-default-props
overscanCount?: number | undefined
}

class VirtualList<T> extends Component<
Props<T>,
{ offset: number; height: number }
> {
focusElement: HTMLElement | null

constructor(props: Props<T>) {
class VirtualList extends Component {
constructor (props) {
super(props)

// The currently focused node, used to retain focus when the visible rows change.
@@ -79,61 +65,58 @@ class VirtualList<T> extends Component<
}
}

componentDidMount(): void {
componentDidMount () {
this.resize()
window.addEventListener('resize', this.handleResize)
}

// TODO: refactor to stable lifecycle method
// eslint-disable-next-line
componentWillUpdate() {
if (this.base!.contains(document.activeElement)) {
this.focusElement = document.activeElement as HTMLElement
componentWillUpdate () {
if (this.base.contains(document.activeElement)) {
this.focusElement = document.activeElement
}
}

componentDidUpdate(): void {
componentDidUpdate () {
// Maintain focus when rows are added and removed.
if (
this.focusElement &&
this.focusElement.parentNode &&
document.activeElement !== this.focusElement
) {
this.focusElement!.focus()
if (this.focusElement && this.focusElement.parentNode
&& document.activeElement !== this.focusElement) {
this.focusElement.focus()
}
this.focusElement = null
this.resize()
}

componentWillUnmount(): void {
componentWillUnmount () {
window.removeEventListener('resize', this.handleResize)
}

handleScroll = (): void => {
this.setState({ offset: (this.base! as HTMLElement).scrollTop })
handleScroll = () => {
this.setState({ offset: this.base.scrollTop })
}

handleResize = (): void => {
handleResize = () => {
this.resize()
}

resize(): void {
resize () {
const { height } = this.state

if (height !== (this.base! as HTMLElement).offsetHeight) {
if (height !== this.base.offsetHeight) {
this.setState({
height: (this.base! as HTMLElement).offsetHeight,
height: this.base.offsetHeight,
})
}
}

render({
render ({
data,
rowHeight,
renderRow,
overscanCount = 10,
...props
}: Props<T>): h.JSX.Element {
}) {
const { offset, height } = this.state
// first visible row index
let start = Math.floor(offset / rowHeight)
2 changes: 1 addition & 1 deletion packages/@uppy/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -5,6 +5,6 @@
"emitDeclarationOnly": false,
"noEmit": true,
},
"include": ["src/*.ts", "src/*.tsx"],
"include": ["src/*.ts"],
"references": [],
}