Some improments and Negentropy (#219)

* feat: adjust default window size

* feat: save window state

* feat: add window state plugin

* feat: add search

* feat: use negentropy for newsfeed

* feat: live feeds

* feat: add search user
This commit is contained in:
雨宮蓮
2024-06-30 14:26:02 +07:00
committed by GitHub
parent 968b1ada94
commit 0fec21b9ce
46 changed files with 5633 additions and 3938 deletions

35
src-tauri/Cargo.lock generated
View File

@@ -2811,6 +2811,7 @@ dependencies = [
"tauri-plugin-theme",
"tauri-plugin-updater",
"tauri-plugin-upload",
"tauri-plugin-window-state",
"tauri-specta",
"tokio",
"url",
@@ -5373,7 +5374,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-clipboard-manager"
version = "2.1.0-beta.4"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"arboard",
"image 0.24.9",
@@ -5404,7 +5405,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-dialog"
version = "2.0.0-beta.9"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"dunce",
"log",
@@ -5421,7 +5422,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-fs"
version = "2.0.0-beta.9"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"anyhow",
"glob",
@@ -5439,7 +5440,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-http"
version = "2.0.0-beta.10"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"data-url",
"http",
@@ -5459,7 +5460,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-notification"
version = "2.0.0-beta.8"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"log",
"notify-rust",
@@ -5477,7 +5478,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-os"
version = "2.0.0-beta.6"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"gethostname",
"log",
@@ -5494,7 +5495,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-process"
version = "2.0.0-beta.6"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"tauri",
"tauri-plugin",
@@ -5503,7 +5504,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-shell"
version = "2.0.0-beta.7"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"encoding_rs",
"log",
@@ -5541,7 +5542,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-updater"
version = "2.0.0-beta.8"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"base64 0.22.1",
"dirs-next",
@@ -5569,7 +5570,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-upload"
version = "2.0.0-beta.7"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#29751ee939fc8d26df07e4da3ad7f5c2aa0926ba"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"futures-util",
"log",
@@ -5584,6 +5585,20 @@ dependencies = [
"tokio-util",
]
[[package]]
name = "tauri-plugin-window-state"
version = "2.0.0-beta.9"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#03d3cc3677bbebd3a8a4f1ab07f9a3bec671b7f5"
dependencies = [
"bitflags 2.6.0",
"log",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"thiserror",
]
[[package]]
name = "tauri-runtime"
version = "2.0.0-beta.18"

View File

@@ -17,12 +17,13 @@ serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
monitor = { git = "https://github.com/ahkohd/tauri-toolkit", branch = "v2" }
tauri = { version = "2.0.0-beta", features = [
"unstable",
"tray-icon",
"macos-private-api",
"native-tls-vendored",
"protocol-asset",
"unstable",
"tray-icon",
"macos-private-api",
"native-tls-vendored",
"protocol-asset",
] }
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
tauri-plugin-clipboard-manager = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
tauri-plugin-fs = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }

View File

@@ -0,0 +1,51 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "desktop-capability",
"description": "Capability for the column",
"platforms": [
"linux",
"macOS",
"windows"
],
"windows": [
"column-*"
],
"permissions": [
"resources:default",
"tray:default",
"os:allow-locale",
"os:allow-os-type",
"clipboard-manager:allow-write-text",
"dialog:allow-open",
"dialog:allow-ask",
"dialog:allow-message",
"fs:allow-read-file",
"menu:default",
"menu:allow-new",
"menu:allow-popup",
"http:default",
"shell:allow-open",
{
"identifier": "http:default",
"allow": [
{
"url": "http://**/"
},
{
"url": "https://**/"
}
]
},
{
"identifier": "fs:allow-read-text-file",
"allow": [
{
"path": "$RESOURCE/locales/*"
},
{
"path": "$RESOURCE/resources/*"
}
]
}
]
}

View File

@@ -1,90 +1,91 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "desktop-capability",
"description": "Capability for the desktop",
"platforms": ["linux", "macOS", "windows"],
"windows": [
"main",
"panel",
"splash",
"settings",
"search",
"nwc",
"activity",
"zap-*",
"event-*",
"user-*",
"editor-*",
"column-*"
],
"permissions": [
"path:default",
"event:default",
"window:default",
"app:default",
"resources:default",
"menu:default",
"tray:default",
"notification:allow-is-permission-granted",
"notification:allow-request-permission",
"notification:default",
"os:allow-locale",
"os:allow-platform",
"os:allow-os-type",
"updater:default",
"updater:allow-check",
"updater:allow-download-and-install",
"window:allow-start-dragging",
"window:allow-create",
"window:allow-close",
"window:allow-destroy",
"window:allow-set-focus",
"window:allow-center",
"window:allow-minimize",
"window:allow-maximize",
"window:allow-set-size",
"window:allow-set-focus",
"window:allow-start-dragging",
"decorum:allow-show-snap-overlay",
"clipboard-manager:allow-write-text",
"clipboard-manager:allow-read-text",
"webview:allow-create-webview-window",
"webview:allow-create-webview",
"webview:allow-set-webview-size",
"webview:allow-set-webview-position",
"webview:allow-webview-close",
"dialog:allow-open",
"dialog:allow-ask",
"dialog:allow-message",
"process:allow-restart",
"fs:allow-read-file",
"theme:allow-set-theme",
"theme:allow-get-theme",
"menu:allow-new",
"menu:allow-popup",
"http:default",
"shell:allow-open",
{
"identifier": "http:default",
"allow": [
{
"url": "http://**/"
},
{
"url": "https://**/"
}
]
},
{
"identifier": "fs:allow-read-text-file",
"allow": [
{
"path": "$RESOURCE/locales/*"
},
{
"path": "$RESOURCE/resources/*"
}
]
}
]
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "desktop-capability",
"description": "Capability for the desktop",
"platforms": [
"linux",
"macOS",
"windows"
],
"windows": [
"main",
"panel",
"settings",
"search-*",
"zap-*",
"event-*",
"user-*",
"editor-*"
],
"permissions": [
"path:default",
"event:default",
"window:default",
"app:default",
"resources:default",
"menu:default",
"tray:default",
"notification:allow-is-permission-granted",
"notification:allow-request-permission",
"notification:default",
"os:allow-locale",
"os:allow-platform",
"os:allow-os-type",
"updater:default",
"updater:allow-check",
"updater:allow-download-and-install",
"window:allow-start-dragging",
"window:allow-create",
"window:allow-close",
"window:allow-destroy",
"window:allow-set-focus",
"window:allow-center",
"window:allow-minimize",
"window:allow-maximize",
"window:allow-set-size",
"window:allow-set-focus",
"window:allow-start-dragging",
"decorum:allow-show-snap-overlay",
"clipboard-manager:allow-write-text",
"clipboard-manager:allow-read-text",
"webview:allow-create-webview-window",
"webview:allow-create-webview",
"webview:allow-set-webview-size",
"webview:allow-set-webview-position",
"webview:allow-webview-close",
"dialog:allow-open",
"dialog:allow-ask",
"dialog:allow-message",
"process:allow-restart",
"process:allow-exit",
"fs:allow-read-file",
"theme:allow-set-theme",
"theme:allow-get-theme",
"menu:allow-new",
"menu:allow-popup",
"http:default",
"shell:allow-open",
{
"identifier": "http:default",
"allow": [
{
"url": "http://**/"
},
{
"url": "https://**/"
}
]
},
{
"identifier": "fs:allow-read-text-file",
"allow": [
{
"path": "$RESOURCE/locales/*"
},
{
"path": "$RESOURCE/resources/*"
}
]
}
]
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","panel","splash","settings","search","nwc","activity","zap-*","event-*","user-*","editor-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","os:allow-os-type","updater:default","updater:allow-check","updater:allow-download-and-install","window:allow-start-dragging","window:allow-create","window:allow-close","window:allow-destroy","window:allow-set-focus","window:allow-center","window:allow-minimize","window:allow-maximize","window:allow-set-size","window:allow-set-focus","window:allow-start-dragging","decorum:allow-show-snap-overlay","clipboard-manager:allow-write-text","clipboard-manager:allow-read-text","webview:allow-create-webview-window","webview:allow-create-webview","webview:allow-set-webview-size","webview:allow-set-webview-position","webview:allow-webview-close","dialog:allow-open","dialog:allow-ask","dialog:allow-message","process:allow-restart","fs:allow-read-file","theme:allow-set-theme","theme:allow-get-theme","menu:allow-new","menu:allow-popup","http:default","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"},{"path":"$RESOURCE/resources/*"}]}],"platforms":["linux","macOS","windows"]}}
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","panel","settings","search-*","zap-*","event-*","user-*","editor-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","os:allow-os-type","updater:default","updater:allow-check","updater:allow-download-and-install","window:allow-start-dragging","window:allow-create","window:allow-close","window:allow-destroy","window:allow-set-focus","window:allow-center","window:allow-minimize","window:allow-maximize","window:allow-set-size","window:allow-set-focus","window:allow-start-dragging","decorum:allow-show-snap-overlay","clipboard-manager:allow-write-text","clipboard-manager:allow-read-text","webview:allow-create-webview-window","webview:allow-create-webview","webview:allow-set-webview-size","webview:allow-set-webview-position","webview:allow-webview-close","dialog:allow-open","dialog:allow-ask","dialog:allow-message","process:allow-restart","process:allow-exit","fs:allow-read-file","theme:allow-set-theme","theme:allow-get-theme","menu:allow-new","menu:allow-popup","http:default","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"},{"path":"$RESOURCE/resources/*"}]}],"platforms":["linux","macOS","windows"]}}

View File

@@ -142,7 +142,7 @@
"identifier": {
"oneOf": [
{
"description": "fs:default -> # Tauri `fs` default permissions\n\nThis configuration file defines the default permissions granted\nto the filesystem.\n\n### Granted Permissions\n\nThis default permission set enables all read-related commands and\nallows access to the `$APP` folder and sub directories created in it.\nThe location of the `$APP` folder depends on the operating system,\nwhere the application is run.\n\nIn general the `$APP` folder needs to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\n### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
"description": "fs:default -> This set of permissions describes the what kind of\nfile system access the `fs` plugin has enabled or denied by default.\n\n#### Granted Permissions\n\nThis default permission set enables read access to the\napplication specific directories (AppConfig, AppData, AppLocalData, AppCache,\nAppLog) and all files and sub directories created in it.\nThe location of these directories depends on the operating system,\nwhere the application is run.\n\nIn general these directories need to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\nTherefore, it is also allowed to create all of these folders via\nthe `mkdir` command.\n\n#### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
"type": "string",
"enum": [
"fs:default"
@@ -1373,6 +1373,13 @@
"fs:allow-write-text-file"
]
},
{
"description": "fs:create-app-specific-dirs -> This permissions allows to create the application specific directories.\n",
"type": "string",
"enum": [
"fs:create-app-specific-dirs"
]
},
{
"description": "fs:deny-copy-file -> Denies the copy_file command without any pre-configured scope.",
"type": "string",
@@ -1562,6 +1569,13 @@
"fs:read-all"
]
},
{
"description": "fs:read-app-specific-dirs-recursive -> This permission allows recursive read functionality on the application\nspecific base directories. \n",
"type": "string",
"enum": [
"fs:read-app-specific-dirs-recursive"
]
},
{
"description": "fs:read-dirs -> This enables directory read and file metadata related commands without any pre-configured accessible paths.",
"type": "string",
@@ -2190,7 +2204,7 @@
"identifier": {
"oneOf": [
{
"description": "http:default -> Allows all fetch operations",
"description": "http:default -> This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n",
"type": "string",
"enum": [
"http:default"
@@ -2313,6 +2327,7 @@
"identifier": {
"oneOf": [
{
"description": "shell:default -> This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
"type": "string",
"enum": [
"shell:default"
@@ -2546,6 +2561,7 @@
]
},
{
"description": "clipboard-manager:default -> No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n",
"type": "string",
"enum": [
"clipboard-manager:default"
@@ -2656,6 +2672,7 @@
]
},
{
"description": "dialog:default -> This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n",
"type": "string",
"enum": [
"dialog:default"
@@ -3852,7 +3869,7 @@
]
},
{
"description": "fs:default -> # Tauri `fs` default permissions\n\nThis configuration file defines the default permissions granted\nto the filesystem.\n\n### Granted Permissions\n\nThis default permission set enables all read-related commands and\nallows access to the `$APP` folder and sub directories created in it.\nThe location of the `$APP` folder depends on the operating system,\nwhere the application is run.\n\nIn general the `$APP` folder needs to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\n### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
"description": "fs:default -> This set of permissions describes the what kind of\nfile system access the `fs` plugin has enabled or denied by default.\n\n#### Granted Permissions\n\nThis default permission set enables read access to the\napplication specific directories (AppConfig, AppData, AppLocalData, AppCache,\nAppLog) and all files and sub directories created in it.\nThe location of these directories depends on the operating system,\nwhere the application is run.\n\nIn general these directories need to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\nTherefore, it is also allowed to create all of these folders via\nthe `mkdir` command.\n\n#### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
"type": "string",
"enum": [
"fs:default"
@@ -4026,6 +4043,13 @@
"fs:allow-write-text-file"
]
},
{
"description": "fs:create-app-specific-dirs -> This permissions allows to create the application specific directories.\n",
"type": "string",
"enum": [
"fs:create-app-specific-dirs"
]
},
{
"description": "fs:deny-copy-file -> Denies the copy_file command without any pre-configured scope.",
"type": "string",
@@ -4215,6 +4239,13 @@
"fs:read-all"
]
},
{
"description": "fs:read-app-specific-dirs-recursive -> This permission allows recursive read functionality on the application\nspecific base directories. \n",
"type": "string",
"enum": [
"fs:read-app-specific-dirs-recursive"
]
},
{
"description": "fs:read-dirs -> This enables directory read and file metadata related commands without any pre-configured accessible paths.",
"type": "string",
@@ -4783,7 +4814,7 @@
]
},
{
"description": "http:default -> Allows all fetch operations",
"description": "http:default -> This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n",
"type": "string",
"enum": [
"http:default"
@@ -5238,12 +5269,61 @@
]
},
{
"description": "notification:default -> Allows requesting permission, checking permission state and sending notifications",
"description": "notification:default -> This permission set configures which\nnotification features are by default exposed.\n\n#### Granted Permissions\n\nIt allows all notification related features.\n\n",
"type": "string",
"enum": [
"notification:default"
]
},
{
"description": "notification:allow-batch -> Enables the batch command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-batch"
]
},
{
"description": "notification:allow-cancel -> Enables the cancel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-cancel"
]
},
{
"description": "notification:allow-check-permissions -> Enables the check_permissions command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-check-permissions"
]
},
{
"description": "notification:allow-create-channel -> Enables the create_channel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-create-channel"
]
},
{
"description": "notification:allow-delete-channel -> Enables the delete_channel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-delete-channel"
]
},
{
"description": "notification:allow-get-active -> Enables the get_active command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-get-active"
]
},
{
"description": "notification:allow-get-pending -> Enables the get_pending command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-get-pending"
]
},
{
"description": "notification:allow-is-permission-granted -> Enables the is_permission_granted command without any pre-configured scope.",
"type": "string",
@@ -5251,6 +5331,13 @@
"notification:allow-is-permission-granted"
]
},
{
"description": "notification:allow-list-channels -> Enables the list_channels command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-list-channels"
]
},
{
"description": "notification:allow-notify -> Enables the notify command without any pre-configured scope.",
"type": "string",
@@ -5258,6 +5345,13 @@
"notification:allow-notify"
]
},
{
"description": "notification:allow-permission-state -> Enables the permission_state command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-permission-state"
]
},
{
"description": "notification:allow-register-action-types -> Enables the register_action_types command without any pre-configured scope.",
"type": "string",
@@ -5272,6 +5366,13 @@
"notification:allow-register-listener"
]
},
{
"description": "notification:allow-remove-active -> Enables the remove_active command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-remove-active"
]
},
{
"description": "notification:allow-request-permission -> Enables the request_permission command without any pre-configured scope.",
"type": "string",
@@ -5279,6 +5380,62 @@
"notification:allow-request-permission"
]
},
{
"description": "notification:allow-show -> Enables the show command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-show"
]
},
{
"description": "notification:deny-batch -> Denies the batch command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-batch"
]
},
{
"description": "notification:deny-cancel -> Denies the cancel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-cancel"
]
},
{
"description": "notification:deny-check-permissions -> Denies the check_permissions command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-check-permissions"
]
},
{
"description": "notification:deny-create-channel -> Denies the create_channel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-create-channel"
]
},
{
"description": "notification:deny-delete-channel -> Denies the delete_channel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-delete-channel"
]
},
{
"description": "notification:deny-get-active -> Denies the get_active command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-get-active"
]
},
{
"description": "notification:deny-get-pending -> Denies the get_pending command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-get-pending"
]
},
{
"description": "notification:deny-is-permission-granted -> Denies the is_permission_granted command without any pre-configured scope.",
"type": "string",
@@ -5286,6 +5443,13 @@
"notification:deny-is-permission-granted"
]
},
{
"description": "notification:deny-list-channels -> Denies the list_channels command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-list-channels"
]
},
{
"description": "notification:deny-notify -> Denies the notify command without any pre-configured scope.",
"type": "string",
@@ -5293,6 +5457,13 @@
"notification:deny-notify"
]
},
{
"description": "notification:deny-permission-state -> Denies the permission_state command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-permission-state"
]
},
{
"description": "notification:deny-register-action-types -> Denies the register_action_types command without any pre-configured scope.",
"type": "string",
@@ -5307,6 +5478,13 @@
"notification:deny-register-listener"
]
},
{
"description": "notification:deny-remove-active -> Denies the remove_active command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-remove-active"
]
},
{
"description": "notification:deny-request-permission -> Denies the request_permission command without any pre-configured scope.",
"type": "string",
@@ -5315,6 +5493,14 @@
]
},
{
"description": "notification:deny-show -> Denies the show command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-show"
]
},
{
"description": "os:default -> This permission set configures which\noperating system information are available\nto gather from the frontend.\n\n#### Granted Permissions\n\nAll information except the host name are available.\n\n",
"type": "string",
"enum": [
"os:default"
@@ -5552,6 +5738,7 @@
]
},
{
"description": "process:default -> This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
"type": "string",
"enum": [
"process:default"
@@ -5607,6 +5794,7 @@
]
},
{
"description": "shell:default -> This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
"type": "string",
"enum": [
"shell:default"
@@ -5878,7 +6066,7 @@
]
},
{
"description": "updater:default -> Allows checking for new updates and installing them",
"description": "updater:default -> This permission set configures which kind of\nupdater functions are exposed to the frontend.\n\n#### Granted Permissions\n\nThe full workflow from checking for updates to installing them\nis enabled.\n\n",
"type": "string",
"enum": [
"updater:default"
@@ -5941,6 +6129,7 @@
]
},
{
"description": "upload:default -> This permission set configures what kind of\noperations are available from the upload plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n",
"type": "string",
"enum": [
"upload:default"
@@ -7037,6 +7226,55 @@
"enum": [
"window:deny-unminimize"
]
},
{
"description": "window-state:default -> This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n",
"type": "string",
"enum": [
"window-state:default"
]
},
{
"description": "window-state:allow-filename -> Enables the filename command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:allow-filename"
]
},
{
"description": "window-state:allow-restore-state -> Enables the restore_state command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:allow-restore-state"
]
},
{
"description": "window-state:allow-save-window-state -> Enables the save_window_state command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:allow-save-window-state"
]
},
{
"description": "window-state:deny-filename -> Denies the filename command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:deny-filename"
]
},
{
"description": "window-state:deny-restore-state -> Denies the restore_state command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:deny-restore-state"
]
},
{
"description": "window-state:deny-save-window-state -> Denies the save_window_state command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:deny-save-window-state"
]
}
]
},

View File

@@ -142,7 +142,7 @@
"identifier": {
"oneOf": [
{
"description": "fs:default -> # Tauri `fs` default permissions\n\nThis configuration file defines the default permissions granted\nto the filesystem.\n\n### Granted Permissions\n\nThis default permission set enables all read-related commands and\nallows access to the `$APP` folder and sub directories created in it.\nThe location of the `$APP` folder depends on the operating system,\nwhere the application is run.\n\nIn general the `$APP` folder needs to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\n### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
"description": "fs:default -> This set of permissions describes the what kind of\nfile system access the `fs` plugin has enabled or denied by default.\n\n#### Granted Permissions\n\nThis default permission set enables read access to the\napplication specific directories (AppConfig, AppData, AppLocalData, AppCache,\nAppLog) and all files and sub directories created in it.\nThe location of these directories depends on the operating system,\nwhere the application is run.\n\nIn general these directories need to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\nTherefore, it is also allowed to create all of these folders via\nthe `mkdir` command.\n\n#### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
"type": "string",
"enum": [
"fs:default"
@@ -1373,6 +1373,13 @@
"fs:allow-write-text-file"
]
},
{
"description": "fs:create-app-specific-dirs -> This permissions allows to create the application specific directories.\n",
"type": "string",
"enum": [
"fs:create-app-specific-dirs"
]
},
{
"description": "fs:deny-copy-file -> Denies the copy_file command without any pre-configured scope.",
"type": "string",
@@ -1562,6 +1569,13 @@
"fs:read-all"
]
},
{
"description": "fs:read-app-specific-dirs-recursive -> This permission allows recursive read functionality on the application\nspecific base directories. \n",
"type": "string",
"enum": [
"fs:read-app-specific-dirs-recursive"
]
},
{
"description": "fs:read-dirs -> This enables directory read and file metadata related commands without any pre-configured accessible paths.",
"type": "string",
@@ -2190,7 +2204,7 @@
"identifier": {
"oneOf": [
{
"description": "http:default -> Allows all fetch operations",
"description": "http:default -> This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n",
"type": "string",
"enum": [
"http:default"
@@ -2313,6 +2327,7 @@
"identifier": {
"oneOf": [
{
"description": "shell:default -> This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
"type": "string",
"enum": [
"shell:default"
@@ -2546,6 +2561,7 @@
]
},
{
"description": "clipboard-manager:default -> No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n",
"type": "string",
"enum": [
"clipboard-manager:default"
@@ -2656,6 +2672,7 @@
]
},
{
"description": "dialog:default -> This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n",
"type": "string",
"enum": [
"dialog:default"
@@ -3852,7 +3869,7 @@
]
},
{
"description": "fs:default -> # Tauri `fs` default permissions\n\nThis configuration file defines the default permissions granted\nto the filesystem.\n\n### Granted Permissions\n\nThis default permission set enables all read-related commands and\nallows access to the `$APP` folder and sub directories created in it.\nThe location of the `$APP` folder depends on the operating system,\nwhere the application is run.\n\nIn general the `$APP` folder needs to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\n### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
"description": "fs:default -> This set of permissions describes the what kind of\nfile system access the `fs` plugin has enabled or denied by default.\n\n#### Granted Permissions\n\nThis default permission set enables read access to the\napplication specific directories (AppConfig, AppData, AppLocalData, AppCache,\nAppLog) and all files and sub directories created in it.\nThe location of these directories depends on the operating system,\nwhere the application is run.\n\nIn general these directories need to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\nTherefore, it is also allowed to create all of these folders via\nthe `mkdir` command.\n\n#### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
"type": "string",
"enum": [
"fs:default"
@@ -4026,6 +4043,13 @@
"fs:allow-write-text-file"
]
},
{
"description": "fs:create-app-specific-dirs -> This permissions allows to create the application specific directories.\n",
"type": "string",
"enum": [
"fs:create-app-specific-dirs"
]
},
{
"description": "fs:deny-copy-file -> Denies the copy_file command without any pre-configured scope.",
"type": "string",
@@ -4215,6 +4239,13 @@
"fs:read-all"
]
},
{
"description": "fs:read-app-specific-dirs-recursive -> This permission allows recursive read functionality on the application\nspecific base directories. \n",
"type": "string",
"enum": [
"fs:read-app-specific-dirs-recursive"
]
},
{
"description": "fs:read-dirs -> This enables directory read and file metadata related commands without any pre-configured accessible paths.",
"type": "string",
@@ -4783,7 +4814,7 @@
]
},
{
"description": "http:default -> Allows all fetch operations",
"description": "http:default -> This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n",
"type": "string",
"enum": [
"http:default"
@@ -5238,12 +5269,61 @@
]
},
{
"description": "notification:default -> Allows requesting permission, checking permission state and sending notifications",
"description": "notification:default -> This permission set configures which\nnotification features are by default exposed.\n\n#### Granted Permissions\n\nIt allows all notification related features.\n\n",
"type": "string",
"enum": [
"notification:default"
]
},
{
"description": "notification:allow-batch -> Enables the batch command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-batch"
]
},
{
"description": "notification:allow-cancel -> Enables the cancel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-cancel"
]
},
{
"description": "notification:allow-check-permissions -> Enables the check_permissions command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-check-permissions"
]
},
{
"description": "notification:allow-create-channel -> Enables the create_channel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-create-channel"
]
},
{
"description": "notification:allow-delete-channel -> Enables the delete_channel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-delete-channel"
]
},
{
"description": "notification:allow-get-active -> Enables the get_active command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-get-active"
]
},
{
"description": "notification:allow-get-pending -> Enables the get_pending command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-get-pending"
]
},
{
"description": "notification:allow-is-permission-granted -> Enables the is_permission_granted command without any pre-configured scope.",
"type": "string",
@@ -5251,6 +5331,13 @@
"notification:allow-is-permission-granted"
]
},
{
"description": "notification:allow-list-channels -> Enables the list_channels command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-list-channels"
]
},
{
"description": "notification:allow-notify -> Enables the notify command without any pre-configured scope.",
"type": "string",
@@ -5258,6 +5345,13 @@
"notification:allow-notify"
]
},
{
"description": "notification:allow-permission-state -> Enables the permission_state command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-permission-state"
]
},
{
"description": "notification:allow-register-action-types -> Enables the register_action_types command without any pre-configured scope.",
"type": "string",
@@ -5272,6 +5366,13 @@
"notification:allow-register-listener"
]
},
{
"description": "notification:allow-remove-active -> Enables the remove_active command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-remove-active"
]
},
{
"description": "notification:allow-request-permission -> Enables the request_permission command without any pre-configured scope.",
"type": "string",
@@ -5279,6 +5380,62 @@
"notification:allow-request-permission"
]
},
{
"description": "notification:allow-show -> Enables the show command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:allow-show"
]
},
{
"description": "notification:deny-batch -> Denies the batch command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-batch"
]
},
{
"description": "notification:deny-cancel -> Denies the cancel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-cancel"
]
},
{
"description": "notification:deny-check-permissions -> Denies the check_permissions command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-check-permissions"
]
},
{
"description": "notification:deny-create-channel -> Denies the create_channel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-create-channel"
]
},
{
"description": "notification:deny-delete-channel -> Denies the delete_channel command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-delete-channel"
]
},
{
"description": "notification:deny-get-active -> Denies the get_active command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-get-active"
]
},
{
"description": "notification:deny-get-pending -> Denies the get_pending command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-get-pending"
]
},
{
"description": "notification:deny-is-permission-granted -> Denies the is_permission_granted command without any pre-configured scope.",
"type": "string",
@@ -5286,6 +5443,13 @@
"notification:deny-is-permission-granted"
]
},
{
"description": "notification:deny-list-channels -> Denies the list_channels command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-list-channels"
]
},
{
"description": "notification:deny-notify -> Denies the notify command without any pre-configured scope.",
"type": "string",
@@ -5293,6 +5457,13 @@
"notification:deny-notify"
]
},
{
"description": "notification:deny-permission-state -> Denies the permission_state command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-permission-state"
]
},
{
"description": "notification:deny-register-action-types -> Denies the register_action_types command without any pre-configured scope.",
"type": "string",
@@ -5307,6 +5478,13 @@
"notification:deny-register-listener"
]
},
{
"description": "notification:deny-remove-active -> Denies the remove_active command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-remove-active"
]
},
{
"description": "notification:deny-request-permission -> Denies the request_permission command without any pre-configured scope.",
"type": "string",
@@ -5315,6 +5493,14 @@
]
},
{
"description": "notification:deny-show -> Denies the show command without any pre-configured scope.",
"type": "string",
"enum": [
"notification:deny-show"
]
},
{
"description": "os:default -> This permission set configures which\noperating system information are available\nto gather from the frontend.\n\n#### Granted Permissions\n\nAll information except the host name are available.\n\n",
"type": "string",
"enum": [
"os:default"
@@ -5552,6 +5738,7 @@
]
},
{
"description": "process:default -> This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
"type": "string",
"enum": [
"process:default"
@@ -5607,6 +5794,7 @@
]
},
{
"description": "shell:default -> This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
"type": "string",
"enum": [
"shell:default"
@@ -5878,7 +6066,7 @@
]
},
{
"description": "updater:default -> Allows checking for new updates and installing them",
"description": "updater:default -> This permission set configures which kind of\nupdater functions are exposed to the frontend.\n\n#### Granted Permissions\n\nThe full workflow from checking for updates to installing them\nis enabled.\n\n",
"type": "string",
"enum": [
"updater:default"
@@ -5941,6 +6129,7 @@
]
},
{
"description": "upload:default -> This permission set configures what kind of\noperations are available from the upload plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n",
"type": "string",
"enum": [
"upload:default"
@@ -7037,6 +7226,55 @@
"enum": [
"window:deny-unminimize"
]
},
{
"description": "window-state:default -> This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n",
"type": "string",
"enum": [
"window-state:default"
]
},
{
"description": "window-state:allow-filename -> Enables the filename command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:allow-filename"
]
},
{
"description": "window-state:allow-restore-state -> Enables the restore_state command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:allow-restore-state"
]
},
{
"description": "window-state:allow-save-window-state -> Enables the save_window_state command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:allow-save-window-state"
]
},
{
"description": "window-state:deny-filename -> Denies the filename command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:deny-filename"
]
},
{
"description": "window-state:deny-restore-state -> Denies the restore_state command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:deny-restore-state"
]
},
{
"description": "window-state:deny-save-window-state -> Denies the save_window_state command without any pre-configured scope.",
"type": "string",
"enum": [
"window-state:deny-save-window-state"
]
}
]
},

View File

@@ -71,6 +71,10 @@ impl Default for Settings {
}
}
pub const FETCH_LIMIT: usize = 20;
pub const NEWSFEED_NEG_LIMIT: usize = 256;
pub const NOTIFICATION_NEG_LIMIT: usize = 64;
fn main() {
let mut ctx = tauri::generate_context!();
@@ -113,9 +117,9 @@ fn main() {
nostr::event::get_event_from,
nostr::event::get_replies,
nostr::event::listen_event_reply,
nostr::event::unlisten_event_reply,
nostr::event::get_events_by,
nostr::event::get_local_events,
nostr::event::listen_local_event,
nostr::event::get_group_events,
nostr::event::get_global_events,
nostr::event::get_hashtag_events,
@@ -124,6 +128,7 @@ fn main() {
nostr::event::repost,
nostr::event::event_to_bech32,
nostr::event::user_to_bech32,
nostr::event::unlisten,
commands::folder::show_in_folder,
commands::window::create_column,
commands::window::close_column,
@@ -263,6 +268,11 @@ fn main() {
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_upload::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(
tauri_plugin_window_state::Builder::new()
.with_denylist(&["panel"])
.build(),
)
.invoke_handler(invoke_handler)
.build(ctx)
.expect("error while running tauri application")

View File

@@ -7,7 +7,7 @@ use specta::Type;
use tauri::State;
use crate::nostr::utils::{create_event_tags, dedup_event, parse_event, Meta};
use crate::Nostr;
use crate::{Nostr, FETCH_LIMIT};
#[derive(Debug, Clone, Serialize, Type)]
pub struct RichEvent {
@@ -197,18 +197,6 @@ pub async fn listen_event_reply(id: &str, state: State<'_, Nostr>) -> Result<(),
Ok(())
}
#[tauri::command]
#[specta::specta]
pub async fn unlisten_event_reply(id: &str, state: State<'_, Nostr>) -> Result<(), ()> {
let client = &state.client;
let sub_id = SubscriptionId::new(id);
// Remove subscription
client.unsubscribe(sub_id).await;
Ok(())
}
#[tauri::command]
#[specta::specta]
pub async fn get_events_by(
@@ -227,7 +215,7 @@ pub async fn get_events_by(
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.author(author)
.limit(20)
.limit(FETCH_LIMIT)
.until(until);
match client.get_events_of(vec![filter], None).await {
@@ -275,17 +263,13 @@ pub async fn get_local_events(
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.limit(20)
.limit(64)
.until(as_of)
.authors(authors);
match client
.get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await
{
match client.database().query(vec![filter], Order::Desc).await {
Ok(events) => {
let dedup = dedup_event(&events);
let futures = dedup.into_iter().map(|ev| async move {
let raw = ev.as_json();
let parsed = if ev.kind == Kind::TextNote {
@@ -296,7 +280,6 @@ pub async fn get_local_events(
RichEvent { raw, parsed }
});
let rich_events = join_all(futures).await;
Ok(rich_events)
@@ -305,6 +288,31 @@ pub async fn get_local_events(
}
}
#[tauri::command]
#[specta::specta]
pub async fn listen_local_event(label: &str, state: State<'_, Nostr>) -> Result<(), String> {
let client = &state.client;
let contact_list = state
.contact_list
.lock()
.map_err(|err| err.to_string())?
.clone();
let authors: Vec<PublicKey> = contact_list.into_iter().map(|f| f.public_key).collect();
let sub_id = SubscriptionId::new(label);
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.authors(authors)
.since(Timestamp::now());
// Subscribe
client.subscribe_with_id(sub_id, vec![filter], None).await;
Ok(())
}
#[tauri::command]
#[specta::specta]
pub async fn get_group_events(
@@ -332,7 +340,7 @@ pub async fn get_group_events(
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.limit(20)
.limit(FETCH_LIMIT)
.until(as_of)
.authors(authors);
@@ -376,7 +384,7 @@ pub async fn get_global_events(
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.limit(20)
.limit(FETCH_LIMIT)
.until(as_of);
match client
@@ -417,7 +425,7 @@ pub async fn get_hashtag_events(
};
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.limit(20)
.limit(FETCH_LIMIT)
.until(as_of)
.hashtags(hashtags);
@@ -663,3 +671,15 @@ pub async fn user_to_bech32(user: &str, state: State<'_, Nostr>) -> Result<Strin
},
}
}
#[tauri::command]
#[specta::specta]
pub async fn unlisten(id: &str, state: State<'_, Nostr>) -> Result<(), ()> {
let client = &state.client;
let sub_id = SubscriptionId::new(id);
// Remove subscription
client.unsubscribe(sub_id).await;
Ok(())
}

View File

@@ -10,7 +10,7 @@ use tauri_plugin_notification::NotificationExt;
use crate::nostr::event::RichEvent;
use crate::nostr::utils::parse_event;
use crate::{Nostr, Settings};
use crate::{Nostr, Settings, NEWSFEED_NEG_LIMIT, NOTIFICATION_NEG_LIMIT};
#[derive(Serialize, Type)]
pub struct Account {
@@ -242,8 +242,9 @@ pub async fn load_account(
};
// Get user's contact list
let contacts = client.get_contact_list(None).await.unwrap();
*state.contact_list.lock().unwrap() = contacts;
if let Ok(contacts) = client.get_contact_list(None).await {
*state.contact_list.lock().unwrap() = contacts
};
// Create a subscription for notification
let sub_id = SubscriptionId::new("notification");
@@ -299,8 +300,9 @@ pub async fn load_account(
let window = handle.get_window("main").unwrap();
let state = window.state::<Nostr>();
let client = &state.client;
let contact_list = state.contact_list.lock().unwrap().clone();
let filter = Filter::new()
let notification = Filter::new()
.pubkey(public_key)
.kinds(vec![
Kind::TextNote,
@@ -308,11 +310,39 @@ pub async fn load_account(
Kind::Reaction,
Kind::ZapReceipt,
])
.limit(500);
.limit(NOTIFICATION_NEG_LIMIT);
match client.reconcile(filter, NegentropyOptions::default()).await {
Ok(_) => println!("Sync notification done."),
match client
.reconcile(notification, NegentropyOptions::default())
.await
{
Ok(_) => {
if handle.emit_to(EventTarget::Any, "synced", true).is_err() {
println!("Emit event failed.")
}
}
Err(_) => println!("Sync notification failed."),
};
if !contact_list.is_empty() {
let authors: Vec<PublicKey> = contact_list.into_iter().map(|f| f.public_key).collect();
let newsfeed = Filter::new()
.authors(authors)
.kinds(vec![Kind::TextNote, Kind::Repost])
.limit(NEWSFEED_NEG_LIMIT);
match client
.reconcile(newsfeed, NegentropyOptions::default())
.await
{
Ok(_) => {
if handle.emit_to(EventTarget::Any, "synced", true).is_err() {
println!("Emit event failed.")
}
}
Err(_) => println!("Sync newsfeed failed."),
}
}
});
@@ -324,7 +354,7 @@ pub async fn load_account(
let client = &state.client;
// Handle notifications
if client
client
.handle_notifications(|notification| async {
if let RelayPoolNotification::Message { message, .. } = notification {
if let RelayMessage::Event {
@@ -415,6 +445,24 @@ pub async fn load_account(
{
println!("Emit new notification failed.")
}
} else if id.starts_with("column-") {
let raw = event.as_json();
let parsed = if event.kind == Kind::TextNote {
Some(parse_event(&event.content).await)
} else {
None
};
if app
.emit_to(
EventTarget::window(id),
"new_event",
RichEvent { raw, parsed },
)
.is_err()
{
println!("Emit new notification failed.")
}
} else {
println!("new event: {}", event.as_json())
}
@@ -425,10 +473,6 @@ pub async fn load_account(
Ok(false)
})
.await
.is_ok()
{
print!("Listing for new event...");
}
});
Ok(true)

View File

@@ -187,13 +187,15 @@ pub async fn is_contact_list_empty(state: State<'_, Nostr>) -> Result<bool, ()>
#[tauri::command]
#[specta::specta]
pub async fn check_contact(hex: &str, state: State<'_, Nostr>) -> Result<bool, ()> {
pub async fn check_contact(hex: &str, state: State<'_, Nostr>) -> Result<bool, String> {
let contact_list = state.contact_list.lock().unwrap();
let public_key = PublicKey::from_str(hex).unwrap();
match contact_list.iter().position(|x| x.public_key == public_key) {
Some(_) => Ok(true),
None => Ok(false),
match PublicKey::from_str(hex) {
Ok(public_key) => match contact_list.iter().position(|x| x.public_key == public_key) {
Some(_) => Ok(true),
None => Ok(false),
},
Err(err) => Err(err.to_string()),
}
}

View File

@@ -1,35 +1,39 @@
{
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
"app": {
"windows": [
{
"title": "Lume",
"label": "main",
"titleBarStyle": "Overlay",
"width": 500,
"height": 800,
"minWidth": 500,
"minHeight": 800,
"hiddenTitle": true,
"windowEffects": {
"state": "followsWindowActiveState",
"effects": ["underWindowBackground"]
}
},
{
"title": "Lume Panel",
"label": "panel",
"url": "/panel",
"width": 350,
"height": 500,
"fullscreen": false,
"resizable": false,
"visible": false,
"decorations": false,
"windowEffects": {
"effects": ["popover"]
}
}
]
}
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
"app": {
"windows": [
{
"title": "Lume",
"label": "main",
"titleBarStyle": "Overlay",
"width": 1045,
"height": 800,
"minWidth": 500,
"minHeight": 800,
"hiddenTitle": true,
"windowEffects": {
"state": "followsWindowActiveState",
"effects": [
"underWindowBackground"
]
}
},
{
"title": "Lume Panel",
"label": "panel",
"url": "/panel",
"width": 350,
"height": 500,
"fullscreen": false,
"resizable": false,
"visible": false,
"decorations": false,
"windowEffects": {
"effects": [
"popover"
]
}
}
]
}
}