diff --git a/package-lock.json b/package-lock.json
index 6590360..007b7aa 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -148,6 +148,12 @@
"@types/node": "*"
}
},
+ "@types/workbox-sw": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/@types/workbox-sw/-/workbox-sw-4.2.0.tgz",
+ "integrity": "sha512-eKk2yrlCuLNmBInQ08FqIcRlMT1ghIo2P7wZW/jAQw0l9ozPYrebcqxnsg2NN+TGRVcMEYGfP05AxmIaxQIArg==",
+ "dev": true
+ },
"@webassemblyjs/ast": {
"version": "1.8.5",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
@@ -3231,9 +3237,9 @@
}
},
"fstream": {
- "version": "1.0.11",
- "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
- "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
+ "version": "1.0.12",
+ "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
+ "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
@@ -7029,13 +7035,13 @@
"dev": true
},
"tar": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
- "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz",
+ "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==",
"dev": true,
"requires": {
"block-stream": "*",
- "fstream": "^1.0.2",
+ "fstream": "^1.0.12",
"inherits": "2"
}
},
@@ -7964,9 +7970,9 @@
}
},
"webpack-dev-server": {
- "version": "3.5.0",
- "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-3.5.0.tgz",
- "integrity": "sha512-Gr4tBz+BRliDy1Jh9YJBOuwf13CipVxf4PCH7alB/rV/heszJ/U8M7KYekzlQn8XvoGgyozw7Uef2GDFd0ZLvg==",
+ "version": "3.5.1",
+ "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-3.5.1.tgz",
+ "integrity": "sha512-0IdMGddJcnK9zesZOeHWl4uAOVfypn7DSrdNWtclROkVBXy/TcBN+6eEG1wNfLT9dXVfaRZZsLTJt0mJtgTQgw==",
"dev": true,
"requires": {
"ansi-html": "0.0.7",
@@ -8593,8 +8599,7 @@
"workbox-core": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-4.3.1.tgz",
- "integrity": "sha512-I3C9jlLmMKPxAC1t0ExCq+QoAMd0vAAHULEgRZ7kieCdUd919n53WC0AfvokHNwqRhGn+tIIj7vcb5duCjs2Kg==",
- "dev": true
+ "integrity": "sha512-I3C9jlLmMKPxAC1t0ExCq+QoAMd0vAAHULEgRZ7kieCdUd919n53WC0AfvokHNwqRhGn+tIIj7vcb5duCjs2Kg=="
},
"workbox-expiration": {
"version": "4.3.1",
@@ -8630,7 +8635,6 @@
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/workbox-precaching/-/workbox-precaching-4.3.1.tgz",
"integrity": "sha512-piSg/2csPoIi/vPpp48t1q5JLYjMkmg5gsXBQkh/QYapCdVwwmKlU9mHdmy52KsDGIjVaqEUMFvEzn2LRaigqQ==",
- "dev": true,
"requires": {
"workbox-core": "^4.3.1"
}
@@ -8648,7 +8652,6 @@
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/workbox-routing/-/workbox-routing-4.3.1.tgz",
"integrity": "sha512-FkbtrODA4Imsi0p7TW9u9MXuQ5P4pVs1sWHK4dJMMChVROsbEltuE79fBoIk/BCztvOJ7yUpErMKa4z3uQLX+g==",
- "dev": true,
"requires": {
"workbox-core": "^4.3.1"
}
@@ -8657,7 +8660,6 @@
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/workbox-strategies/-/workbox-strategies-4.3.1.tgz",
"integrity": "sha512-F/+E57BmVG8dX6dCCopBlkDvvhg/zj6VDs0PigYwSN23L8hseSRwljrceU2WzTvk/+BSYICsWmRq5qHS2UYzhw==",
- "dev": true,
"requires": {
"workbox-core": "^4.3.1"
}
diff --git a/package.json b/package.json
index f1ef740..b9911ed 100755
--- a/package.json
+++ b/package.json
@@ -23,12 +23,16 @@
"lodash.clonedeep": "^4.5.0",
"secure-file-wrapper": "git+https://git.stamm.me/OpenServer/OSSecureFileWrapper.git",
"uikit": "^3.1.5",
- "uuid": "^3.3.2"
+ "uuid": "^3.3.2",
+ "workbox-precaching": "^4.3.1",
+ "workbox-routing": "^4.3.1",
+ "workbox-strategies": "^4.3.1"
},
"devDependencies": {
"@types/lodash.clonedeep": "^4.5.6",
"@types/uikit": "^2.27.7",
"@types/uuid": "^3.4.4",
+ "@types/workbox-sw": "^4.2.0",
"copy-webpack-plugin": "^5.0.3",
"css-loader": "^2.1.1",
"file-loader": "^3.0.1",
@@ -44,7 +48,7 @@
"webpack": "^4.32.2",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.2",
- "webpack-dev-server": "^3.5.0",
+ "webpack-dev-server": "^3.5.1",
"webpack-visualizer-plugin": "^0.1.11",
"workbox-webpack-plugin": "^4.3.1",
"worker-loader": "^2.0.0"
diff --git a/public/manifest.json b/public/manifest.json
index e418643..2e0fd38 100755
--- a/public/manifest.json
+++ b/public/manifest.json
@@ -3,10 +3,9 @@
"name": "Secure Notes",
"decription": "A place to store your notes securly",
"share_target": {
- "url_template": "/#/share?title={title}&text={text}&url={url}",
+ "action": "/share",
"method": "GET",
"enctype": "application/x-www-form-urlencoded",
- "action": "/",
"params": {
"title": "title",
"text": "text",
diff --git a/public/serviceworker.js b/public/serviceworker.js
index 8eaf4f9..0301b94 100644
--- a/public/serviceworker.js
+++ b/public/serviceworker.js
@@ -6,6 +6,7 @@ const CACHE = "offline";
let precacheFiles = [
"/",
+ "/index.html",
"/main.js",
"/main.css",
"/serviceworker.js"
@@ -46,6 +47,7 @@ var Types;
Types[Types["CACHE"] = 0] = "CACHE";
Types[Types["NOCACHE"] = 1] = "NOCACHE";
Types[Types["REFRESH"] = 2] = "REFRESH";
+ Types[Types["INDEX"] = 3] = "INDEX";
})(Types || (Types = {}));
let rules = [{
@@ -53,6 +55,11 @@ let rules = [{
return url.indexOf("/api/") >= 0;
},
type: Types.NOCACHE
+ }, {
+ match: (url) => {
+ return url.indexOf("/share") >= 0;
+ },
+ type: Types.INDEX
},
{
match: () => {
@@ -77,6 +84,11 @@ self.addEventListener('fetch', (evt) => {
});
case Types.NOCACHE:
return fetch(evt.request);
+ case Types.INDEX:
+ return refresh(new Request("/")).then(r => {
+ evt.waitUntil(r.refresh.catch(_ => {}));
+ return r.result;
+ })
}
})());
});
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx
index 87a9393..5006aaa 100644
--- a/src/components/Footer.tsx
+++ b/src/components/Footer.tsx
@@ -65,7 +65,7 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
Welcome {Notes.name}
- v1.1
+ v1.2
}
diff --git a/src/components/notifications.tsx b/src/components/notifications.tsx
index 926718e..763b33e 100644
--- a/src/components/notifications.tsx
+++ b/src/components/notifications.tsx
@@ -1,5 +1,4 @@
import { h, Component } from "preact";
-import Notes from "../notes";
import "./notifications.scss"
import Notifications, { MessageType } from "../notifications";
@@ -37,11 +36,11 @@ export default class NotificationsComponent extends Component<{}, {
this.setState({ notifications: n });
setTimeout(() => {
this.removeNot(not);
- }, 3000);
+ }, 20000);
}
removeNot(not: { message: string }) {
- let n = this.state.notifications.slice(0).filter(e => e !== not);
+ let n = this.state.notifications.filter(e => e !== not);
this.setState({ notifications: n });
}
diff --git a/src/components/routes/404/index.tsx b/src/components/routes/404/index.tsx
new file mode 100644
index 0000000..499f288
--- /dev/null
+++ b/src/components/routes/404/index.tsx
@@ -0,0 +1,5 @@
+import { h } from "preact";
+
+export default function Error404Page() {
+ return
Page not found!
;
+}
\ No newline at end of file
diff --git a/src/components/routes/share/Share.tsx b/src/components/routes/share/Share.tsx
index 34c19e5..f777ad3 100644
--- a/src/components/routes/share/Share.tsx
+++ b/src/components/routes/share/Share.tsx
@@ -6,7 +6,7 @@ import Navigation from "../../../navigation";
export default class SharePage extends Page<{ state: any }, { vault: string }> {
text: string;
componentWillMount() {
- let { title, text, url } = Navigation.getQuery() || {} as any;
+ let { title, text, url } = this.props.state;
let note = "";
if (title) {
note += title + "\n"
@@ -24,7 +24,9 @@ export default class SharePage extends Page<{ state: any }, { vault: string }> {
render() {
return {
- Navigation.setPage("/vault", { id: vault }, { entry: "true", note: this.text }, true);
+ Navigation.setPage("/", undefined, undefined, true);
+ Navigation.setPage("/vault", { id: vault });
+ Navigation.setPage("/vault", { id: vault }, { entry: "true", note: this.text });
}} />
}
}
diff --git a/src/components/routes/vault/EntryList.tsx b/src/components/routes/vault/EntryList.tsx
index 129cee6..5df4d94 100755
--- a/src/components/routes/vault/EntryList.tsx
+++ b/src/components/routes/vault/EntryList.tsx
@@ -74,17 +74,30 @@ export default class EntryList extends Component<{ vault: Promise }, { n
}
}
+ const deleteNote = async () => {
+ Notes.delete(note._id).then(() => {
+ Notifications.sendSuccess("Deleted")
+ this.rawNotes = this.rawNotes.filter(e => e._id !== note._id);
+ this.setState({ notes: this.state.notes.filter(e => e._id !== note._id) });
+ }).catch(err => {
+ Notifications.sendError(err);
+ })
+
+ }
+
let share;
if ((window.navigator as any).share) {
- share =