Version History (#768)
* Stash. Super rough progress * Stash * 'h' how toggles history panel Add documents.restore endpoint * Add tests for documents.restore endpoint * Document restore endpoint * Tiding, RevisionMenu, remove scroll dep * Add history menu item * Paginate loading * Fixed: Error boundary styling Select first revision faster * Diff summary, styling * Add history loading placeholder Fix move modal not opening * Fixes: Refreshing page on specific revision * documentation for document.revision * Better handle versions with no text changes (will no longer be created)
This commit is contained in:
@@ -7,7 +7,7 @@ import stores from 'stores';
|
||||
import parseTitle from '../../shared/utils/parseTitle';
|
||||
import unescape from '../../shared/utils/unescape';
|
||||
|
||||
import type { NavigationNode, User } from 'types';
|
||||
import type { NavigationNode, Revision, User } from 'types';
|
||||
import BaseModel from './BaseModel';
|
||||
import Collection from './Collection';
|
||||
|
||||
@@ -110,6 +110,22 @@ class Document extends BaseModel {
|
||||
}
|
||||
};
|
||||
|
||||
@action
|
||||
restore = async (revision: Revision) => {
|
||||
try {
|
||||
const res = await client.post('/documents.restore', {
|
||||
id: this.id,
|
||||
revisionId: revision.id,
|
||||
});
|
||||
runInAction('Document#save', () => {
|
||||
invariant(res && res.data, 'Data should be available');
|
||||
this.updateData(res.data);
|
||||
});
|
||||
} catch (e) {
|
||||
this.ui.showToast('Document failed to restore');
|
||||
}
|
||||
};
|
||||
|
||||
@action
|
||||
pin = async () => {
|
||||
this.pinned = true;
|
||||
|
||||
Reference in New Issue
Block a user