Temporary folder (part 3)
This commit is contained in:
parent
c5e0f3e2e4
commit
7c0bf68ad3
@ -18,6 +18,7 @@ import SplashScreen from './SplashScreen';
|
||||
import syncSvc from '../services/syncSvc';
|
||||
import networkSvc from '../services/networkSvc';
|
||||
import sponsorSvc from '../services/sponsorSvc';
|
||||
import tempFileSvc from '../services/tempFileSvc';
|
||||
import timeSvc from '../services/timeSvc';
|
||||
import store from '../store';
|
||||
|
||||
@ -94,6 +95,7 @@ export default {
|
||||
networkSvc.init();
|
||||
sponsorSvc.init();
|
||||
this.ready = true;
|
||||
tempFileSvc.setReady();
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err && err.message !== 'reload') {
|
||||
|
@ -119,8 +119,13 @@ export default {
|
||||
editorSvc.init(editorElt, previewElt, tocElt);
|
||||
|
||||
// Focus on the editor every time reader mode is disabled
|
||||
this.$watch(() => this.styles.showEditor,
|
||||
showEditor => showEditor && editorSvc.clEditor.focus());
|
||||
const focus = () => {
|
||||
if (this.styles.showEditor) {
|
||||
editorSvc.clEditor.focus();
|
||||
}
|
||||
};
|
||||
setTimeout(focus, 100);
|
||||
this.$watch(() => this.styles.showEditor, focus);
|
||||
},
|
||||
destroyed() {
|
||||
window.removeEventListener('resize', this.updateStyle);
|
||||
|
@ -6,6 +6,7 @@ import welcomeFile from '../data/welcomeFile.md';
|
||||
const dbVersion = 1;
|
||||
const dbStoreName = 'objects';
|
||||
const exportWorkspace = utils.queryParams.exportWorkspace;
|
||||
const silent = utils.queryParams.silent;
|
||||
const resetApp = utils.queryParams.reset;
|
||||
const deleteMarkerMaxAge = 1000;
|
||||
const checkSponsorshipAfter = (5 * 60 * 1000) + (30 * 1000); // tokenExpirationMargin + 30 sec
|
||||
@ -195,6 +196,10 @@ const localDbSvc = {
|
||||
* Write all changes from the store since previous transaction.
|
||||
*/
|
||||
writeAll(storeItemMap, tx) {
|
||||
if (silent) {
|
||||
// Skip writing to DB in silent mode
|
||||
return;
|
||||
}
|
||||
const dbStore = tx.objectStore(dbStoreName);
|
||||
const incrementedTx = this.lastTx + 1;
|
||||
|
||||
|
@ -9,6 +9,11 @@ const contentText = utils.queryParams.contentText;
|
||||
const contentProperties = utils.queryParams.contentProperties;
|
||||
|
||||
export default {
|
||||
setReady() {
|
||||
if (origin && window.parent) {
|
||||
window.parent.postMessage({ type: 'ready' }, origin);
|
||||
}
|
||||
},
|
||||
closed: false,
|
||||
close() {
|
||||
if (!this.closed && origin && window.parent) {
|
||||
@ -22,9 +27,10 @@ export default {
|
||||
}
|
||||
|
||||
store.commit('setLight', true);
|
||||
|
||||
return store.dispatch('createFile', {
|
||||
name: fileName,
|
||||
text: contentText,
|
||||
name: fileName || utils.getHostname(origin),
|
||||
text: contentText || '\n',
|
||||
properties: contentProperties,
|
||||
parentId: 'temp',
|
||||
})
|
||||
@ -67,11 +73,11 @@ export default {
|
||||
const properties = utils.computeProperties(content.properties);
|
||||
window.parent.postMessage({
|
||||
type: 'fileChange',
|
||||
file: {
|
||||
payload: {
|
||||
id: file.id,
|
||||
name: currentFile.name,
|
||||
content: {
|
||||
text: content.text,
|
||||
text: content.text.slice(0, -1), // Remove trailing LF
|
||||
properties,
|
||||
yamlProperties: content.properties,
|
||||
html: editorSvc.previewCtx.html,
|
||||
@ -83,7 +89,7 @@ export default {
|
||||
|
||||
// Watch preview refresh and file name changes
|
||||
editorSvc.$on('previewCtx', onChange);
|
||||
store.$watch(() => store.getters['file/current'].name, onChange);
|
||||
store.watch(() => store.getters['file/current'].name, onChange);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user