diff options
author | Ellie Huxtable <ellie@elliehuxtable.com> | 2024-01-17 09:58:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-17 09:58:09 +0000 |
commit | d9317a1a9c14dd1919f3e04537b01d5a14f8aaea (patch) | |
tree | 8a338df6a2e534a3f694fd93852abbf716e1fbcc /atuin-client | |
parent | ef38fd0a294b63bb48919ccbc2f8cd16201fa622 (diff) |
feat: make deleting from the UI work with record store sync (#1580)
* feat: make deleting from the UI work with record store sync
* sort cli delete too
* teeny bit more logs
Diffstat (limited to 'atuin-client')
-rw-r--r-- | atuin-client/src/api_client.rs | 2 | ||||
-rw-r--r-- | atuin-client/src/history/store.rs | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs index 7b3735991..affb3c982 100644 --- a/atuin-client/src/api_client.rs +++ b/atuin-client/src/api_client.rs @@ -286,6 +286,8 @@ impl<'a> Client<'a> { let url = format!("{}/api/v0/record", self.sync_addr); let url = Url::parse(url.as_str())?; + debug!("uploading {} records to {url}", records.len()); + let resp = self.client.post(url).json(records).send().await?; handle_resp_error(resp).await?; diff --git a/atuin-client/src/history/store.rs b/atuin-client/src/history/store.rs index a77854528..ab88182a1 100644 --- a/atuin-client/src/history/store.rs +++ b/atuin-client/src/history/store.rs @@ -114,7 +114,7 @@ impl HistoryStore { } } - async fn push_record(&self, record: HistoryRecord) -> Result<RecordIdx> { + async fn push_record(&self, record: HistoryRecord) -> Result<(RecordId, RecordIdx)> { let bytes = record.serialize()?; let idx = self .store @@ -130,20 +130,22 @@ impl HistoryStore { .data(bytes) .build(); + let id = record.id; + self.store .push(&record.encrypt::<PASETO_V4>(&self.encryption_key)) .await?; - Ok(idx) + Ok((id, idx)) } - pub async fn delete(&self, id: HistoryId) -> Result<RecordIdx> { + pub async fn delete(&self, id: HistoryId) -> Result<(RecordId, RecordIdx)> { let record = HistoryRecord::Delete(id); self.push_record(record).await } - pub async fn push(&self, history: History) -> Result<RecordIdx> { + pub async fn push(&self, history: History) -> Result<(RecordId, RecordIdx)> { // TODO(ellie): move the history store to its own file // it's tiny rn so fine as is let record = HistoryRecord::Create(history); |