Web: Editor: Moved the functionality of converting history and getting the current version into separate functions.
This commit is contained in:
parent
944591cd4d
commit
1983d60e55
@ -495,17 +495,10 @@ const Editor = () => {
|
||||
document.location.reload();
|
||||
};
|
||||
|
||||
const onSDKRequestHistory = async () => {
|
||||
try {
|
||||
let fileHistory = await getEditHistory(fileId);
|
||||
|
||||
let newArr = [];
|
||||
const getDocumentHistory = (fileHistory) => {
|
||||
let result = [];
|
||||
console.log("fileHistory", fileHistory);
|
||||
const historyLength = fileHistory.length;
|
||||
const currentVersion =
|
||||
url.indexOf("&version=") !== -1
|
||||
? +url.split("&version=")[1]
|
||||
: fileHistory[historyLength - 1].version;
|
||||
|
||||
for (let i = 0; i < historyLength; i++) {
|
||||
const changes = fileHistory[i].changes;
|
||||
@ -528,12 +521,24 @@ const Editor = () => {
|
||||
versionGroup,
|
||||
};
|
||||
|
||||
newArr.push(obj);
|
||||
result.push(obj);
|
||||
}
|
||||
console.log("newArr", newArr);
|
||||
console.log("newArr", result);
|
||||
return result;
|
||||
};
|
||||
const currentDocumentVersion = (fileHistory) => {
|
||||
const historyLength = fileHistory.length;
|
||||
return url.indexOf("&version=") !== -1
|
||||
? +url.split("&version=")[1]
|
||||
: fileHistory[historyLength - 1].version;
|
||||
};
|
||||
const onSDKRequestHistory = async () => {
|
||||
try {
|
||||
let fileHistory = await getEditHistory(fileId);
|
||||
|
||||
docEditor.refreshHistory({
|
||||
currentVersion,
|
||||
history: newArr,
|
||||
currentVersion: currentDocumentVersion(fileHistory),
|
||||
history: getDocumentHistory(fileHistory),
|
||||
});
|
||||
} catch (e) {
|
||||
docEditor.refreshHistory({
|
||||
|
Loading…
Reference in New Issue
Block a user