mirror of
https://github.com/ente-io/ente.git
synced 2025-08-14 02:07:33 +00:00
dis 2
This commit is contained in:
@@ -296,16 +296,17 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
||||
const isFavorite = useCallback(
|
||||
({ file }: FileViewerAnnotatedFile) => {
|
||||
if (!showModifyActions || !favoriteFileIDs) return undefined;
|
||||
favoriteFileIDs.has(file.id);
|
||||
return favoriteFileIDs.has(file.id);
|
||||
},
|
||||
[showModifyActions, favoriteFileIDs],
|
||||
);
|
||||
|
||||
const toggleFavorite = useCallback(
|
||||
({ file, annotation }: FileViewerAnnotatedFile) => {
|
||||
async ({ file, annotation }: FileViewerAnnotatedFile) => {
|
||||
if (!showModifyActions || !favoriteFileIDs)
|
||||
throw new Error("Unexpected invocation");
|
||||
|
||||
await new Promise((r) => setTimeout(r, 7000));
|
||||
console.log({ file, annotation });
|
||||
// TODO
|
||||
// const isFavorite = annotation.isFavorite;
|
||||
|
@@ -493,15 +493,20 @@ export class FileViewerPhotoSwipe {
|
||||
});
|
||||
|
||||
if (showModifyActions) {
|
||||
const toggleFavorite = async () => {
|
||||
const toggleFavorite = async (
|
||||
buttonElement: HTMLButtonElement,
|
||||
value: boolean,
|
||||
) => {
|
||||
const af = currentAnnotatedFile();
|
||||
this.pendingFavoriteUpdates.add(af.file.id);
|
||||
buttonElement.disabled = true;
|
||||
await delegate.toggleFavorite(af);
|
||||
this.pendingFavoriteUpdates.delete(af.file.id);
|
||||
showFavoriteIf(buttonElement, value);
|
||||
};
|
||||
|
||||
const forIsFavorite = (
|
||||
buttonElement: HTMLElement,
|
||||
const showFavoriteIf = (
|
||||
buttonElement: HTMLButtonElement,
|
||||
value: boolean,
|
||||
) => {
|
||||
const af = currentAnnotatedFile();
|
||||
@@ -520,10 +525,10 @@ export class FileViewerPhotoSwipe {
|
||||
order: 8,
|
||||
isButton: true,
|
||||
html: createPSRegisterElementIconHTML("favorite"),
|
||||
onClick: toggleFavorite,
|
||||
onClick: (e) => toggleFavorite(e.target, false),
|
||||
onInit: (buttonElement) =>
|
||||
pswp.on("change", () =>
|
||||
forIsFavorite(buttonElement, false),
|
||||
showFavoriteIf(buttonElement, false),
|
||||
),
|
||||
});
|
||||
pswp.ui.registerElement({
|
||||
@@ -532,10 +537,10 @@ export class FileViewerPhotoSwipe {
|
||||
order: 8,
|
||||
isButton: true,
|
||||
html: createPSRegisterElementIconHTML("unfavorite"),
|
||||
onClick: toggleFavorite,
|
||||
onClick: (e) => toggleFavorite(e.target),
|
||||
onInit: (buttonElement) =>
|
||||
pswp.on("change", () =>
|
||||
forIsFavorite(buttonElement, true),
|
||||
showFavoriteIf(buttonElement, true),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user