fix bug save when nagivating away

master
Niko PLP 3 months ago
parent 86a64d7ef5
commit 30f93e0797
  1. 2
      ng-app/index-web.html
  2. 2
      ng-app/src/apps/MdSource.svelte
  3. 3
      ng-app/src/apps/MilkDownEditor.svelte
  4. 2
      ng-app/src/apps/PostMdViewer.svelte
  5. 1
      ng-app/src/apps/YMapEditor.svelte
  6. 1
      ng-app/src/apps/YMapViewer.svelte
  7. 3
      ng-app/src/locales/en.json
  8. 16
      ng-app/src/store.ts
  9. 9
      ng-app/src/tab.ts
  10. 2
      ng-app/src/workertest.js
  11. 1
      ng-repo/src/errors.rs
  12. 5
      ng-verifier/src/commits/transaction.rs
  13. 7
      ng-verifier/src/verifier.rs

@ -119,7 +119,7 @@
if (RegExp().hasIndices === undefined) return false;
try {
if (Worker === undefined) return false;
new Worker(URL.createObjectURL(new Blob(['console.log("webworker ok");'], {type: 'application/javascript'})));
new Worker(URL.createObjectURL(new Blob([';'], {type: 'application/javascript'})));
if (typeof WebAssembly === "object"
&& typeof WebAssembly.instantiate === "function") {
const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));

@ -104,6 +104,7 @@
}
onMount(async ()=>{
if (editor) await editor.destroy();
await setup();
});
@ -112,6 +113,7 @@
ydoc.destroy();
commits.discrete?.deregisterOnUpdate();
if (editor) await editor.destroy();
editor = undefined;
});

@ -181,7 +181,7 @@
}
onMount(async ()=>{
if (editor) await editor.destroy();
await setup();
});
@ -189,6 +189,7 @@
onDestroy(async ()=>{
ydoc.destroy();
if (editor) await editor.destroy();
editor = undefined;
});
</script>

@ -129,6 +129,7 @@
}
onMount(async ()=>{
if (editor) await editor.destroy();
await setup();
});
@ -137,6 +138,7 @@
ydoc.destroy();
try {
if (editor) await editor.destroy();
editor = undefined;
} catch(e) {
console.log(e);
}

@ -254,6 +254,7 @@
onDestroy(async ()=>{
ydoc.destroy();
await editor.destroy();
editor = undefined;
});
function onRenderMenu(items, context) {

@ -125,6 +125,7 @@
onDestroy(async ()=>{
ydoc.destroy();
await editor.destroy();
editor = undefined;
});
const edit = () => {

@ -19,7 +19,7 @@
"pro": "Pro",
"media": "Media",
"chart": "Chart",
"viz": "Vizualitation",
"viz": "Visualization",
"diagram": "Diagram",
"other": "Other file formats",
"data": "Data",
@ -555,6 +555,7 @@
"DecryptionError": "Error with decryption.",
"InvalidValue": "The value is invalid.",
"ConnectionNotFound": "The connection was not found.",
"InvalidSecurityImage": "The security image you chose is not valid.",
"InvalidKey": "The key is invalid.",
"InvalidInvitation": "The invitation is invalid.",
"InvalidCreateAccount": "An error occurred creating the account.",

@ -17,7 +17,7 @@ import {
} from "svelte/store";
import { register, init, locale, format } from "svelte-i18n";
import ng from "./api";
import { persistent_error, update_class, update_branch_display, open_branch, tab_update, change_nav_bar, cur_branch, cur_tab, show_modal_create, cur_tab_update, nav_bar,in_memory_save } from "./tab";
import { persistent_error, update_class, update_branch_display, open_branch, tab_update, change_nav_bar, cur_branch, cur_tab, show_modal_create, save, nav_bar,in_memory_save } from "./tab";
import { encode } from "./base64url";
let all_branches = {};
@ -47,6 +47,7 @@ init({
export const display_error = (error: string) => {
if (error.message) return error.message;
if (error.includes(" ")) return error;
if (error.includes("\"")) return error;
//console.log(error);
// TODO: Check, if error tranlsation does not exist
const parts = error.split(":");
@ -143,6 +144,7 @@ export const toast_success = (text) => {
}
export const openModalCreate = async () => {
await save();
await reset_toasts()
show_modal_create.set(true);
}
@ -464,6 +466,7 @@ export const sparql_update = async function(sparql:string) {
}
export const branch_subscribe = function(nuri:string, in_tab:boolean) {
//console.log("branch_subscribe", nuri)
// const { subscribe, set, update } = writable([]); // create the underlying writable store
@ -492,12 +495,14 @@ export const branch_subscribe = function(nuri:string, in_tab:boolean) {
// // update,
// };
open_branch(nuri, in_tab);
return {
load: async () => {
//console.log("load upper");
await save();
open_branch(nuri, in_tab);
let already_subscribed = all_branches[nuri];
if (!already_subscribed) return;
if (already_subscribed.load) {
@ -696,7 +701,10 @@ export const branch_subscribe = function(nuri:string, in_tab:boolean) {
});
} else {
console.error(e);
// TODO: display persistent_error
persistent_error(nuri, {
title: get(format)("errors.an_error_occurred"),
desc: display_error(e)
});
}
}
// this is in case decrease has been called before the load function returned.

@ -335,9 +335,11 @@ export const save = async () => {
nav_bar.update((o) => { if (o.save === true) o.save = false; return o; });
if (in_memory_save.length > 0) {
await in_memory_save_callback(in_memory_save);
let temp = in_memory_save;
in_memory_save = [];
await in_memory_save_callback(temp);
}
in_memory_save = [];
}
export const set_header_in_view = function(val) {
@ -469,7 +471,8 @@ export const cur_tab_update = function( fn ) {
export const live_editing = writable(false);
export const showMenu = () => {
export const showMenu = async () => {
await save();
show_modal_menu.set(true);
cur_tab_update(ct => {
ct.show_menu = true;

@ -1 +1 @@
console.log("workertest ok");
;

@ -405,6 +405,7 @@ impl From<NgError> for VerifierError {
NgError::BranchNotFound => VerifierError::BranchNotFound,
NgError::SerializationError => VerifierError::SerializationError,
NgError::PermissionDenied => VerifierError::PermissionDenied,
NgError::VerifierError(e) => e,
// NgError::JsStorageReadError
// NgError::JsStorageWriteError(String)
// NgError::JsStorageKeyNotFound

@ -229,7 +229,10 @@ impl Verifier {
(BranchCrdt::YMap(_), DiscreteTransaction::YMap(v)) => DiscretePatch::YMap(v),
(BranchCrdt::YText(_), DiscreteTransaction::YText(v)) => DiscretePatch::YText(v),
(BranchCrdt::YXml(_), DiscreteTransaction::YXml(v)) => DiscretePatch::YXml(v),
_ => return Err(VerifierError::InvalidCommit),
_ => {
//log_debug!("{:?} {:?}", crdt, patch);
return Err(VerifierError::InvalidCommit);
}
};
self.push_app_response(
branch_id,

@ -1415,6 +1415,7 @@ impl Verifier {
let broker_id = if as_publisher {
if branch_info.topic_priv_key.is_none() {
// we need to subscribe as publisher, but we cant
log_debug!("no topic_priv_key");
return Err(NgError::PermissionDenied);
}
Some(remote_broker.broker_peer_id())
@ -1990,8 +1991,7 @@ impl Verifier {
repo_id,
Arc::clone(&store),
)
.await
.map_err(|e| NgError::BootstrapError(e.to_string()))?;
.await?;
let mut store_branch = None;
@ -2028,8 +2028,7 @@ impl Verifier {
repo_id,
Arc::clone(&store),
)
.await
.map_err(|e| NgError::BootstrapError(e.to_string()))?;
.await?;
}
}

Loading…
Cancel
Save