editor: improve edit propagation
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/579/head
parent
6e0003dc10
commit
6b25ad6780
|
@ -190,6 +190,10 @@ class ImageController extends GenericApiController
|
||||||
// Get the image info
|
// Get the image info
|
||||||
$info = $this->timelineQuery->getInfoById($file->getId(), $basic);
|
$info = $this->timelineQuery->getInfoById($file->getId(), $basic);
|
||||||
|
|
||||||
|
// Add fileid and etag
|
||||||
|
$info['fileid'] = $file->getId();
|
||||||
|
$info['etag'] = $file->getEtag();
|
||||||
|
|
||||||
// Allow these ony for logged in users
|
// Allow these ony for logged in users
|
||||||
if (null !== $this->userSession->getUser()) {
|
if (null !== $this->userSession->getUser()) {
|
||||||
// Get list of tags for this file
|
// Get list of tags for this file
|
||||||
|
@ -347,10 +351,7 @@ class ImageController extends GenericApiController
|
||||||
// Make sure the preview is updated
|
// Make sure the preview is updated
|
||||||
\OC::$server->get(\OCP\IPreview::class)->getPreview($file);
|
\OC::$server->get(\OCP\IPreview::class)->getPreview($file);
|
||||||
|
|
||||||
return new JSONResponse([
|
return $this->info((string) $file->getId(), true);
|
||||||
'fileid' => $file->getId(),
|
|
||||||
'etag' => $file->getEtag(),
|
|
||||||
], Http::STATUS_OK);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { FilerobotImageEditorConfig } from "react-filerobot-image-editor";
|
||||||
import translations from "./ImageEditorTranslations";
|
import translations from "./ImageEditorTranslations";
|
||||||
|
|
||||||
import { API } from "../../services/API";
|
import { API } from "../../services/API";
|
||||||
import { IPhoto } from "../../types";
|
import { IImageInfo, IPhoto } from "../../types";
|
||||||
import * as utils from "../../services/Utils";
|
import * as utils from "../../services/Utils";
|
||||||
import { fetchImage } from "../frame/XImgCache";
|
import { fetchImage } from "../frame/XImgCache";
|
||||||
|
|
||||||
|
@ -234,14 +234,17 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await axios.put(API.IMAGE_EDIT(this.photo.fileid), {
|
const res = await axios.put<IImageInfo>(
|
||||||
|
API.IMAGE_EDIT(this.photo.fileid),
|
||||||
|
{
|
||||||
name: name,
|
name: name,
|
||||||
width: data.width,
|
width: data.width,
|
||||||
height: data.height,
|
height: data.height,
|
||||||
quality: data.quality,
|
quality: data.quality,
|
||||||
extension: data.extension,
|
extension: data.extension,
|
||||||
state: state,
|
state: state,
|
||||||
});
|
}
|
||||||
|
);
|
||||||
const fileid = res.data.fileid;
|
const fileid = res.data.fileid;
|
||||||
|
|
||||||
// Success, emit an appropriate event
|
// Success, emit an appropriate event
|
||||||
|
@ -250,6 +253,7 @@ export default defineComponent({
|
||||||
if (fileid !== this.photo.fileid) {
|
if (fileid !== this.photo.fileid) {
|
||||||
emit("files:file:created", { fileid });
|
emit("files:file:created", { fileid });
|
||||||
} else {
|
} else {
|
||||||
|
utils.updatePhotoFromImageInfo(this.photo, res.data);
|
||||||
emit("files:file:updated", { fileid });
|
emit("files:file:updated", { fileid });
|
||||||
}
|
}
|
||||||
this.onClose(undefined, false);
|
this.onClose(undefined, false);
|
||||||
|
|
|
@ -398,8 +398,6 @@ export default defineComponent({
|
||||||
const photo = this.currentPhoto;
|
const photo = this.currentPhoto;
|
||||||
const isvideo = photo && photo.flag & this.c.FLAG_IS_VIDEO;
|
const isvideo = photo && photo.flag & this.c.FLAG_IS_VIDEO;
|
||||||
if (photo && !isvideo && photo.fileid === fileid) {
|
if (photo && !isvideo && photo.fileid === fileid) {
|
||||||
photo.etag += "_";
|
|
||||||
photo.imageInfo = null;
|
|
||||||
this.photoswipe.refreshSlideContent(this.currIndex);
|
this.photoswipe.refreshSlideContent(this.currIndex);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IPhoto } from "../../types";
|
import { IImageInfo, IPhoto } from "../../types";
|
||||||
import { API } from "../API";
|
import { API } from "../API";
|
||||||
|
|
||||||
/** Get preview URL from photo object */
|
/** Get preview URL from photo object */
|
||||||
|
@ -25,6 +25,21 @@ export function getPreviewUrl(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update photo object using imageInfo.
|
||||||
|
*/
|
||||||
|
export function updatePhotoFromImageInfo(photo: IPhoto, imageInfo: IImageInfo) {
|
||||||
|
photo.etag = imageInfo.etag;
|
||||||
|
photo.basename = imageInfo.basename;
|
||||||
|
photo.mimetype = imageInfo.mimetype;
|
||||||
|
photo.w = imageInfo.w;
|
||||||
|
photo.h = imageInfo.h;
|
||||||
|
photo.imageInfo = {
|
||||||
|
...photo.imageInfo,
|
||||||
|
...imageInfo,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the path of the folder on folders route
|
* Get the path of the folder on folders route
|
||||||
* This function does not check if this is the folder route
|
* This function does not check if this is the folder route
|
||||||
|
|
|
@ -76,6 +76,8 @@ export type IPhoto = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IImageInfo {
|
export interface IImageInfo {
|
||||||
|
fileid: number;
|
||||||
|
etag: string;
|
||||||
h: number;
|
h: number;
|
||||||
w: number;
|
w: number;
|
||||||
datetaken: number;
|
datetaken: number;
|
||||||
|
|
Loading…
Reference in New Issue