Sync tweaks
parent
4c39d0b964
commit
9c04db6a9c
|
@ -155,8 +155,6 @@ let quitting = false;
|
||||||
|
|
||||||
const icon = nativeImage.createFromPath(process.resourcesPath + "/logo.png");
|
const icon = nativeImage.createFromPath(process.resourcesPath + "/logo.png");
|
||||||
export function newWindow(instance: Instance, windowState: WindowState) {
|
export function newWindow(instance: Instance, windowState: WindowState) {
|
||||||
// Create the browser window.
|
|
||||||
console.log("Empty icon?", icon.isEmpty());
|
|
||||||
const window = new BrowserWindow({
|
const window = new BrowserWindow({
|
||||||
height: windowState.height,
|
height: windowState.height,
|
||||||
width: windowState.width,
|
width: windowState.width,
|
||||||
|
|
|
@ -165,6 +165,12 @@ const template: MenuItemConstructorOptions[] = [
|
||||||
{
|
{
|
||||||
label: "Help",
|
label: "Help",
|
||||||
submenu: [
|
submenu: [
|
||||||
|
{
|
||||||
|
label: "Documentation",
|
||||||
|
click: () => {
|
||||||
|
shell.openExternal("https://silverbullet.md");
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
role: "about",
|
role: "about",
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,6 +7,8 @@ export type AppEvent =
|
||||||
| "minieditor:complete"
|
| "minieditor:complete"
|
||||||
| "page:load"
|
| "page:load"
|
||||||
| "editor:init"
|
| "editor:init"
|
||||||
|
| "editor:pageLoaded"
|
||||||
|
| "editor:pageReloaded"
|
||||||
| "editor:modeswitch"
|
| "editor:modeswitch"
|
||||||
| "plugs:loaded";
|
| "plugs:loaded";
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,10 @@ export async function updatePlugs() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
if (e.message.includes("Could not read file")) {
|
||||||
|
console.warn("No PLUGS page found, not loading anything");
|
||||||
|
return;
|
||||||
|
}
|
||||||
throw new Error(`Error processing PLUGS: ${e.message}`);
|
throw new Error(`Error processing PLUGS: ${e.message}`);
|
||||||
}
|
}
|
||||||
console.log("Plug YAML", plugList);
|
console.log("Plug YAML", plugList);
|
||||||
|
|
|
@ -5,6 +5,11 @@ functions:
|
||||||
command:
|
command:
|
||||||
name: "Sync: Configure"
|
name: "Sync: Configure"
|
||||||
|
|
||||||
|
disableCommand:
|
||||||
|
path: sync.ts:disableCommand
|
||||||
|
command:
|
||||||
|
name: "Sync: Disable"
|
||||||
|
|
||||||
syncCommand:
|
syncCommand:
|
||||||
path: sync.ts:syncCommand
|
path: sync.ts:syncCommand
|
||||||
command:
|
command:
|
||||||
|
@ -16,6 +21,11 @@ functions:
|
||||||
command:
|
command:
|
||||||
name: "Sync: Wipe Local Space and Sync"
|
name: "Sync: Wipe Local Space and Sync"
|
||||||
|
|
||||||
|
syncOpenedPage:
|
||||||
|
path: sync.ts:syncOpenedPage
|
||||||
|
events:
|
||||||
|
- editor:pageLoaded
|
||||||
|
|
||||||
check:
|
check:
|
||||||
env: server
|
env: server
|
||||||
path: sync.ts:check
|
path: sync.ts:check
|
||||||
|
@ -23,8 +33,10 @@ functions:
|
||||||
performSync:
|
performSync:
|
||||||
env: server
|
env: server
|
||||||
path: sync.ts:performSync
|
path: sync.ts:performSync
|
||||||
|
# Sync every minute
|
||||||
cron: "* * * * *"
|
cron: "* * * * *"
|
||||||
|
|
||||||
|
# Automatically sync the current page upon change
|
||||||
syncPage:
|
syncPage:
|
||||||
path: sync.ts:syncPage
|
path: sync.ts:syncPage
|
||||||
env: server
|
env: server
|
||||||
|
|
|
@ -68,6 +68,20 @@ export async function syncCommand() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function disableCommand() {
|
||||||
|
if (
|
||||||
|
!(await editor.confirm(
|
||||||
|
"Are you sure you want to disable sync?",
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove all sync related keys from the store
|
||||||
|
await store.deletePrefix("sync.");
|
||||||
|
await editor.flashNotification("Sync disabled.");
|
||||||
|
}
|
||||||
|
|
||||||
export async function localWipeAndSyncCommand() {
|
export async function localWipeAndSyncCommand() {
|
||||||
let config: SyncEndpoint | undefined = await store.get("sync.config");
|
let config: SyncEndpoint | undefined = await store.get("sync.config");
|
||||||
if (!config) {
|
if (!config) {
|
||||||
|
@ -112,6 +126,22 @@ export async function localWipeAndSyncCommand() {
|
||||||
|
|
||||||
// Starting actual sync
|
// Starting actual sync
|
||||||
await syncCommand();
|
await syncCommand();
|
||||||
|
|
||||||
|
// And finally loading all plugs
|
||||||
|
await system.invokeFunction("client", "core.updatePlugsCommand");
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function syncOpenedPage() {
|
||||||
|
// Is sync on?
|
||||||
|
if (!(await store.has("sync.config"))) {
|
||||||
|
// Nope -> exit
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await system.invokeFunction(
|
||||||
|
"server",
|
||||||
|
"syncPage",
|
||||||
|
await editor.getCurrentPage(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run on server
|
// Run on server
|
||||||
|
@ -119,8 +149,8 @@ export function check(config: SyncEndpoint) {
|
||||||
return sync.check(config);
|
return sync.check(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a sync takes longer than this, we'll consider it timed out
|
||||||
const syncTimeout = 1000 * 60 * 10; // 10 minutes
|
const syncTimeout = 1000 * 60 * 10; // 10 minutes
|
||||||
// const syncTimeout = 1000 * 20; // 20s
|
|
||||||
|
|
||||||
// Run on server
|
// Run on server
|
||||||
export async function performSync() {
|
export async function performSync() {
|
||||||
|
|
|
@ -3,8 +3,15 @@ release.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Next
|
## 0.2.11
|
||||||
* Regression fix: hashtag completion works again
|
* Regression fix: hashtag completion works again
|
||||||
|
* Sync improvements:
|
||||||
|
* Immediately trigger sync on file when opened in the editor (so you always get the latest version)
|
||||||
|
* Automatically perform a {[Plugs: Update]} after performing a {[Sync: Wipe Local Space and Sync]}
|
||||||
|
* New {[Sync: Disable]} command to disable sync (remove config and snapshot)
|
||||||
|
* {[Plugs: Update]} no longer fails when there is no [[PLUGS]] file.
|
||||||
|
* Desktop: New “Help” menu with link to documentation (silverbullet.md website) and About box with version number.
|
||||||
|
* You now see a clear error message when querying an non-supported query source.
|
||||||
|
|
||||||
---
|
---
|
||||||
## 0.2.10
|
## 0.2.10
|
||||||
|
|
Loading…
Reference in New Issue