Skip to content

Commit

Permalink
Merge branch 'release' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmz committed May 8, 2024
2 parents e54a532 + 3c6ad03 commit 7dbfb74
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Experimental

## [1.131.3] - 2024-05-08
### Fixed
- Separate local and remote file list changes in the file uploader (finish the
fix in 1.131.1).

## [1.131.2] - 2024-05-08
### Fixed
- Programmatic insertion into the comment text area is now debounced with a
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reactive-pepyatka",
"version": "1.131.2",
"version": "1.131.3",
"description": "",
"main": "index.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function Footer({ short }) {
return (
<footer className="footer">
<p role="navigation">
&copy; FreeFeed 1.131.2-beta (May 8, 2024)
&copy; FreeFeed 1.131.3-beta (May 8, 2024)
<br />
<Link to="/about">About</Link>
{' | '}
Expand Down
24 changes: 15 additions & 9 deletions src/components/uploader/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ export function useUploader({

// Attachments management
const [fileIds, setFileIds] = useState(() => getDraft(draftKey)?.fileIds ?? initialFileIds);
const updatedLocally = useRef(false);
const setFileIdsLocally = useCallback((arg) => {
setFileIds(arg);
updatedLocally.current = true;
}, []);

const removeFile = useCallback(
(idToRemove) => setFileIds((ids) => ids.filter((id) => id !== idToRemove)),
[],
(idToRemove) => setFileIdsLocally((ids) => ids.filter((id) => id !== idToRemove)),
[setFileIdsLocally],
);
const reorderFiles = useCallback(
(reorderedIds) => setFileIds((oldIds) => uniq(reorderedIds.concat(oldIds))),
[],
(reorderedIds) => setFileIdsLocally((oldIds) => uniq(reorderedIds.concat(oldIds))),
[setFileIdsLocally],
);

useEffect(() => {
Expand All @@ -49,9 +54,10 @@ export function useUploader({
}, [draftKey, initialFileIds]);

useEffect(() => {
if (!draftKey) {
if (!draftKey || !updatedLocally.current) {
return;
}
updatedLocally.current = false;
const st = store.getState();
setDraftField(
draftKey,
Expand Down Expand Up @@ -112,11 +118,11 @@ export function useUploader({
for (const id of uploadIds) {
if (statuses[id]?.success && unfinishedFiles.has(id)) {
unfinishedFiles.delete(id);
setFileIds((ids) => [...ids, allUploads[id].attachment.id]);
setFileIdsLocally((ids) => [...ids, allUploads[id].attachment.id]);
onSuccess?.(allUploads[id].attachment, id);
}
}
}, [allUploads, onSuccess, statuses, unfinishedFiles, uploadIds]);
}, [allUploads, onSuccess, setFileIdsLocally, statuses, unfinishedFiles, uploadIds]);

const uploadProgressProps = useMemo(
() => ({ uploadIds, statuses, unfinishedFiles }),
Expand All @@ -136,8 +142,8 @@ export function useUploader({
const clearUploads = useCallback(() => {
uploadIds.clear();
unfinishedFiles.clear();
setFileIds(initialFileIds);
}, [initialFileIds, unfinishedFiles, uploadIds]);
setFileIdsLocally(initialFileIds);
}, [initialFileIds, setFileIdsLocally, unfinishedFiles, uploadIds]);

return {
isUploading,
Expand Down
2 changes: 1 addition & 1 deletion src/services/drafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function trimDraftPrefix(storageKey) {
* @returns {boolean}
*/
function isUnchangedData(data1, data2) {
return data2 === data1 || isEqual(omit(data1, 'ts'), omit(data2, 'ts'));
return data2 === data1 || isEqual(omit(data1, ['ts', 'files']), omit(data2, ['ts', 'files']));
}

/**
Expand Down

0 comments on commit 7dbfb74

Please sign in to comment.