Skip to content

Commit 7995ccc

Browse files
committed
Added permissions for microphone and camera.
1 parent 13868e6 commit 7995ccc

File tree

17 files changed

+248
-48
lines changed

17 files changed

+248
-48
lines changed

Cargo.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fluster/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pyo3 = "0.25.1"
9090
ndarray = { version = "0.16.1", features = ["rayon", "serde"] }
9191
numpy = "0.25.0"
9292
kalosm = { version = "0.4.0", features = ["full"] }
93+
serde_yml = "0.0.12"
9394

9495
[target.'cfg(target_os = "macos")'.dependencies]
9596
kalosm = { version = "0.4.0", features = ["full", "metal"] }
Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
{
2-
"$schema": "../gen/schemas/desktop-schema.json",
3-
"identifier": "default",
4-
"description": "Capability for the main window",
5-
"windows": [
6-
"main"
7-
],
8-
"permissions": [
9-
"core:default",
10-
"opener:default",
11-
"log:default",
12-
"dialog:default",
13-
"opener:default",
14-
"opener:default"
15-
]
16-
}
2+
"$schema": "../gen/schemas/desktop-schema.json",
3+
"identifier": "default",
4+
"description": "Capability for the main window",
5+
"windows": [
6+
"main"
7+
],
8+
"permissions": [
9+
"core:default",
10+
"core:window:allow-start-dragging",
11+
"log:allow-log",
12+
"log:default",
13+
"dialog:allow-open",
14+
"dialog:allow-save",
15+
"opener:allow-open-url",
16+
"opener:allow-reveal-item-in-dir",
17+
{
18+
"identifier": "opener:allow-open-path",
19+
"allow": [
20+
{
21+
"path": "*"
22+
}
23+
]
24+
}
25+
]
26+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSCameraUsageDescription</key>
6+
<string>Request camera access for WebRTC</string>
7+
<key>NSMicrophoneUsageDescription</key>
8+
<string>Request microphone access for WebRTC</string>
9+
</dict>
10+
</plist>

apps/fluster/src-tauri/src/core/models/taggable/shared_taggable_model.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ pub struct SharedTaggableModel {
1010
pub ctime: String,
1111
}
1212

13+
#[derive(Type, Serialize, Deserialize, Debug, Clone)]
14+
pub struct SharedTaggableModelWithExists {
15+
pub value: String,
16+
pub ctime: String,
17+
pub exists: bool,
18+
}
19+
1320
impl SharedTaggableModel {
1421
pub fn new(val: String, ctime: Option<FlusterDateTime>) -> SharedTaggableModel {
1522
let _ctime = match ctime {

apps/fluster/src-tauri/src/core/sync/parse_directory/sync_fs_directory/models/sync_filesystem_options.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use serde::{Deserialize, Serialize};
22
use specta::Type;
33

4+
use crate::features::taggables::commands::get_existing_taggables::AllTaggableData;
5+
46
#[derive(Type, Serialize, Deserialize, Debug)]
57
pub struct SyncFilesystemDirectoryOptions {
68
pub dir_path: String,
@@ -10,16 +12,22 @@ pub struct SyncFilesystemDirectoryOptions {
1012
pub use_git_ignore: bool,
1113
/// defaults to true
1214
pub with_ai: bool,
15+
pub existing_taggables: AllTaggableData,
1316
}
1417

1518
impl Default for SyncFilesystemDirectoryOptions {
1619
fn default() -> Self {
1720
Self {
1821
dir_path: Default::default(),
1922
bib_path: Default::default(),
20-
n_threads: "8".to_string(),
23+
n_threads: "16".to_string(),
2124
use_git_ignore: false,
2225
with_ai: true,
26+
existing_taggables: AllTaggableData {
27+
tags: Vec::new(),
28+
topics: Vec::new(),
29+
subjects: Vec::new(),
30+
},
2331
}
2432
}
2533
}

apps/fluster/src-tauri/src/core/sync/parse_directory/sync_fs_directory/sync_methods/sync_mdx_notes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ pub async fn sync_mdx_filesystem_notes(opts: &SyncFilesystemDirectoryOptions) ->
5858
LocalAiClient {}
5959
.get_text_embeddings(&mut items, opts.with_ai)
6060
.await?;
61-
save_mdx_note_groups(&db, items).await?;
61+
save_mdx_note_groups(&db, items, opts.existing_taggables.clone()).await?;
6262
Ok(())
6363
}

apps/fluster/src-tauri/src/features/mdx/actions/save_mdx_note_groups.rs

Lines changed: 92 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
use std::str::FromStr;
22

3-
use chrono::Utc;
3+
use chrono::{DateTime, FixedOffset, Utc};
44

55
use crate::{
66
core::{
77
models::taggable::{
8-
shared_taggable_model::SharedTaggableModel, subject_entity::SubjectEntity,
9-
tag_entity::TagEntity, topic_entity::TopicEntity,
8+
shared_taggable_model::{SharedTaggableModel, SharedTaggableModelWithExists},
9+
subject_entity::SubjectEntity,
10+
tag_entity::TagEntity,
11+
topic_entity::TopicEntity,
1012
},
1113
sync::parse_directory::sync_fs_directory::sync_methods::clean::clean_database,
1214
types::{errors::errors::FlusterResult, FlusterDb},
@@ -31,10 +33,14 @@ use crate::{
3133
mdx_note_tag_model::MdxNoteTagModel, mdx_note_topic_entity::MdxNoteTopicEntity,
3234
mdx_note_topic_model::MdxNoteTopicModel,
3335
},
36+
taggables::commands::get_existing_taggables::AllTaggableData,
3437
},
3538
};
3639

37-
fn taggable_vec_exists(t: &[SharedTaggableModel], new_taggable: &SharedTaggableModel) -> bool {
40+
fn taggable_vec_exists(
41+
t: &[SharedTaggableModelWithExists],
42+
new_taggable: &SharedTaggableModel,
43+
) -> bool {
3844
for k in t {
3945
if k.value == new_taggable.value {
4046
return true;
@@ -45,7 +51,10 @@ fn taggable_vec_exists(t: &[SharedTaggableModel], new_taggable: &SharedTaggableM
4551

4652
// FIXME: Come back here and handle reformatting of the date here.
4753
fn reformat_date(d: &str) -> String {
48-
// chrono::DateTime::<Utc>::from(value)
54+
let format = "%Y-%m-%dT%H:%M:%S";
55+
let datetime: Result<DateTime<FixedOffset>, chrono::ParseError> =
56+
chrono::DateTime::parse_from_str(d, format);
57+
println!("Datetime: {:?}", datetime);
4958
if let Ok(res) = chrono::DateTime::<Utc>::from_str(d) {
5059
return res.timestamp_millis().to_string();
5160
}
@@ -59,36 +68,37 @@ fn reformat_date(d: &str) -> String {
5968
pub async fn save_mdx_note_groups(
6069
db: &FlusterDb<'_>,
6170
groups: Vec<MdxNoteGroup>,
71+
existing_taggables: AllTaggableData,
6272
) -> FlusterResult<()> {
6373
clean_database(db).await?;
6474
// Loop over each item and generate the proper joining tables.
6575
let mut equations: Vec<EquationModel> = Vec::new();
6676
let mut mdx_note_equations: Vec<MdxNoteEquationModel> = Vec::new();
67-
let mut tags: Vec<SharedTaggableModel> = TagEntity::get_many(db)
68-
.await
69-
.unwrap_or(Vec::new())
77+
let mut tags: Vec<SharedTaggableModelWithExists> = existing_taggables
78+
.tags
7079
.iter()
71-
.map(|x| SharedTaggableModel {
80+
.map(|x| SharedTaggableModelWithExists {
7281
value: x.value.clone(),
7382
ctime: reformat_date(&x.ctime),
83+
exists: true,
7484
})
7585
.collect();
76-
let mut subjects: Vec<SharedTaggableModel> = SubjectEntity::get_all(db)
77-
.await
78-
.unwrap_or(Vec::new())
86+
let mut subjects: Vec<SharedTaggableModelWithExists> = existing_taggables
87+
.subjects
7988
.iter()
80-
.map(|x| SharedTaggableModel {
89+
.map(|x| SharedTaggableModelWithExists {
8190
value: x.value.clone(),
8291
ctime: reformat_date(&x.ctime),
92+
exists: true,
8393
})
8494
.collect();
85-
let mut topics: Vec<SharedTaggableModel> = TopicEntity::get_all(db)
86-
.await
87-
.unwrap_or(Vec::new())
95+
let mut topics: Vec<SharedTaggableModelWithExists> = existing_taggables
96+
.topics
8897
.iter()
89-
.map(|x| SharedTaggableModel {
98+
.map(|x| SharedTaggableModelWithExists {
9099
value: x.value.clone(),
91100
ctime: reformat_date(&x.ctime),
101+
exists: true,
92102
})
93103
.collect();
94104
let mut mdx_note_tags: Vec<MdxNoteTagModel> = Vec::new();
@@ -132,7 +142,11 @@ pub async fn save_mdx_note_groups(
132142
}
133143
for t in item.tags.clone() {
134144
if !taggable_vec_exists(&tags, &t) {
135-
tags.push(t.clone());
145+
tags.push(SharedTaggableModelWithExists {
146+
value: t.value.clone(),
147+
ctime: t.ctime.clone(),
148+
exists: false,
149+
});
136150
}
137151
if !mdx_note_tags
138152
.iter()
@@ -147,7 +161,11 @@ pub async fn save_mdx_note_groups(
147161
if item.front_matter.subject.is_some() {
148162
let s = item.front_matter.subject.as_ref().unwrap();
149163
if !taggable_vec_exists(&subjects, s) {
150-
subjects.push(s.clone());
164+
subjects.push(SharedTaggableModelWithExists {
165+
value: s.value.clone(),
166+
ctime: s.ctime.clone(),
167+
exists: false,
168+
});
151169
}
152170
if !mdx_note_subjects
153171
.iter()
@@ -163,7 +181,11 @@ pub async fn save_mdx_note_groups(
163181
if item.front_matter.topic.is_some() {
164182
let t = item.front_matter.topic.as_ref().unwrap();
165183
if !taggable_vec_exists(&topics, t) {
166-
topics.push(t.clone());
184+
topics.push(SharedTaggableModelWithExists {
185+
value: t.value.clone(),
186+
ctime: t.ctime.clone(),
187+
exists: false,
188+
});
167189
}
168190
if !mdx_note_topics
169191
.iter()
@@ -182,9 +204,56 @@ pub async fn save_mdx_note_groups(
182204
// an idiot.
183205
// EquationEntity::save_many(db, equations).await?;
184206
MdxNoteEquationEntity::save_many(db, mdx_note_equations).await?;
185-
TagEntity::save_many(db, tags).await?;
186-
SubjectEntity::create_many(db, subjects).await?;
187-
TopicEntity::create_many(db, topics).await?;
207+
TagEntity::save_many(
208+
db,
209+
tags.iter()
210+
.filter_map(|t| {
211+
if t.exists {
212+
None
213+
} else {
214+
Some(SharedTaggableModel {
215+
value: t.value.clone(),
216+
ctime: t.ctime.clone(),
217+
})
218+
}
219+
})
220+
.collect(),
221+
)
222+
.await?;
223+
SubjectEntity::create_many(
224+
db,
225+
subjects
226+
.iter()
227+
.filter_map(|t| {
228+
if t.exists {
229+
None
230+
} else {
231+
Some(SharedTaggableModel {
232+
value: t.value.clone(),
233+
ctime: t.ctime.clone(),
234+
})
235+
}
236+
})
237+
.collect(),
238+
)
239+
.await?;
240+
TopicEntity::create_many(
241+
db,
242+
topics
243+
.iter()
244+
.filter_map(|t| {
245+
if t.exists {
246+
None
247+
} else {
248+
Some(SharedTaggableModel {
249+
value: t.value.clone(),
250+
ctime: t.ctime.clone(),
251+
})
252+
}
253+
})
254+
.collect(),
255+
)
256+
.await?;
188257
MdxNoteTagEntity::create_many(db, mdx_note_tags).await?;
189258
MdxNoteSubjectEntity::create_many(db, mdx_note_subjects).await?;
190259
MdxNoteTopicEntity::create_many(db, mdx_note_topics).await?;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
use crate::core::{
4+
database::db::get_database,
5+
models::taggable::{
6+
shared_taggable_model::SharedTaggableModel, subject_entity::SubjectEntity,
7+
tag_entity::TagEntity, topic_entity::TopicEntity,
8+
},
9+
};
10+
11+
#[derive(Serialize, Deserialize, specta::Type, Debug, Clone)]
12+
pub struct AllTaggableData {
13+
pub tags: Vec<SharedTaggableModel>,
14+
pub topics: Vec<SharedTaggableModel>,
15+
pub subjects: Vec<SharedTaggableModel>,
16+
}
17+
18+
#[tauri::command]
19+
#[specta::specta]
20+
pub async fn get_existing_taggables() -> AllTaggableData {
21+
let db_res = get_database().await;
22+
let db = db_res.lock().await;
23+
let (tags, topics, subjects) = tokio::join!(
24+
TagEntity::get_many(&db),
25+
TopicEntity::get_all(&db),
26+
SubjectEntity::get_all(&db),
27+
);
28+
AllTaggableData {
29+
tags: tags.unwrap_or(Vec::new()),
30+
topics: topics.unwrap_or(Vec::new()),
31+
subjects: subjects.unwrap_or(Vec::new()),
32+
}
33+
}

0 commit comments

Comments
 (0)