Skip to content

Commit

Permalink
chore: delete no longer relevant todo comments, commented out code
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyg committed Oct 27, 2024
1 parent c903a1a commit e5bc308
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 89 deletions.
2 changes: 0 additions & 2 deletions dnas/relay/zomes/coordinator/relay/src/contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ pub fn get_latest_contact(
}
None => original_contact_hash.clone(),
};
//get(latest_contact_hash, GetOptions::default())
// TODO: is this best practice or should we just return the Record?
match get(latest_contact_hash, GetOptions::default())? {
Some(record) => {
Ok(Some(ContactRecord {
Expand Down
77 changes: 2 additions & 75 deletions dnas/relay/zomes/coordinator/relay/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use hdk::prelude::*;
use relay_integrity::*;

use crate::get_entry_for_action;
// use chrono::{DateTime, Utc, Datelike};
// use crate::utils::*;

#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
Expand All @@ -22,18 +20,7 @@ pub fn create_message(input: SendMessageInput) -> ExternResult<Record> {
.to_string())
),
)?;
// let now: DateTime<Utc> = Utc::now();
// let year = now.year();
// let month = now.month();
// let week = now.iso_week().week();
// let formatted_date = format!("{}/{}/{}", year, month, week);
// let path = Path::from(formatted_date);
// create_link_relaxed(
// path.path_entry_hash()?,
// AnyLinkableHash::try_from(record.action_address().clone())?,
// LinkTypes::MessageBlock,
// (),
// )?;

let path = messages_path(input.message.bucket);
debug!("create_message path {:?}", path);
let link = create_link(
Expand All @@ -43,7 +30,6 @@ pub fn create_message(input: SendMessageInput) -> ExternResult<Record> {
(),
)?;

// TODO: handle errors. look for ack, try again on fail
let _ = send_remote_signal(
MessageRecord {
message: Some(input.message),
Expand All @@ -57,44 +43,6 @@ pub fn create_message(input: SendMessageInput) -> ExternResult<Record> {
Ok(record)
}

// pub struct MessageBlock {
// week: String,
// count: u32,
// hashes: SignedActionHashed,
// }

// pub struct GetMessageHashesForWeekInput {
// pub week: String,
// pub message_count_already_loaded: u8,
// }
// #[hdk_extern]
// pub fn get_messages_hashes_for_week(
// input: GetMessageHashesForWeekInput,
// ) -> ExternResult<MessageBlock> {
// let weekString = input.week;
// if (weekString.is_empty()) {
// let now: DateTime<Utc> = Utc::now();
// let year = now.year();
// let month = now.month();
// let week = now.iso_week().week();
// weekString = format!("{}/{}/{}", year, month, week);
// }
// let path = Path::from(weekString);
// //let links = get_links(path.path_entry_hash()?, LinkTypes::MessageBlock, None)?;
// let links = get_links(
// GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::MessageBlock)?
// .build(),
// );
// let mut results = Vec::new();
// for l in links {
// let hash = ActionHash::try_from(l.target).map_err(|e| wasm_error!(e))?;
// if let Some(r) = get_latest_message(hash)? {
// results.push(r);
// }
// }
// Ok(results)
// }

#[derive(Serialize, Deserialize, Debug)]
pub struct BucketInput {
pub bucket: u32,
Expand Down Expand Up @@ -149,35 +97,14 @@ pub fn get_message_entries(hashes: Vec<ActionHash>) -> ExternResult<Vec<MessageR
Ok(results)
}

// TODO deprecate
#[hdk_extern]
pub fn get_messages_for_buckets(buckets: Vec<u32>) -> ExternResult<Vec<MessageRecord>> {
let links = get_message_links_for_buckets(buckets)?;
let mut results: Vec<MessageRecord> = Vec::new();
for l in links {
let hash = ActionHash::try_from(l.target).map_err(|e|wasm_error!(e))?;
if let Some(r) = get_latest_message(hash)? {
// TODO: make a call to the profiles zome to get the agent profile
// TODO: why did i think this was necessary ??
// let call_input = GetAgenProfileInput {
// agent_key: r.signed_action.hashed.author().clone(),
// };
// let agent = call(
// CallTargetCell::Local,
// "profiles",
// "get_agent_profile".into(),
// None,
// call_input,
// );
// if let ZomeCallResponse::Ok(response) = call(CallTargetCell::Local,"profiles",FunctionName::new("get_agent_profile"), None, call_input)? {
// let agent : Record<Profile> = response.decode().map_err(|_e| wasm_error!(WasmErrorInner::Guest(String::from("could not decode agent profile"))))?;
// // let me = agent_info()?.agent_latest_pubkey;
// //let agents = agents.into_iter().filter(|a| a != &me).collect();
// debug!("agent {:?}", agent);
// r.message.unwrap().author_name = agent;
// }

results.push (r);
results.push(r);
}
}

Expand Down
3 changes: 1 addition & 2 deletions ui/src/lib/LightboxImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
items: [
{
// Because we don't know the original image dimensions,
// we scale by 10x and let bigger-picture handle constaining within window
// TODO: use the original image dimensions either by publishing to DHT or determining after downloading image
// we scale by 10x and let bigger-picture handle constraining within window
width: targetImg.width * 10,
height: targetImg.height * 10,
img: src,
Expand Down
12 changes: 7 additions & 5 deletions ui/src/routes/conversations/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
})
}
const checkForData = () => {
checkForAgents()
checkForConfig()
checkForMessages()
}
function handleResize() {
if (scrollAtBottom) {
scrollToBottom();
Expand All @@ -96,10 +102,7 @@
// messages = c.messages;
numMembers = Object.values(agentProfiles).length;
});
// TODO: do this check in one call of checkForStuff
checkForAgents()
checkForConfig()
checkForMessages()
checkForData();
conversationContainer.addEventListener('scroll', handleScroll);
window.addEventListener('resize', debouncedHandleResize);
newMessageInput.focus();
Expand Down Expand Up @@ -130,7 +133,6 @@
messages.forEach(message => {
// Don't display message if we don't have a profile from the author yet.
// TODO: could wait until all profiles have been synced first?
if (!agentProfiles[message.authorKey]) {
return;
}
Expand Down
2 changes: 0 additions & 2 deletions ui/src/routes/conversations/[id]/invite/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
}
async function addContactsToConversation() {
// TODO: update config.title?
if (conversation) {
conversation.addContacts($selectedContacts)
goto(`/conversations/${conversation.id}/details`)
Expand Down
3 changes: 1 addition & 2 deletions ui/src/store/ConversationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class ConversationStore {
}

const invitation: Invitation = {
created: this.created, // TODO: put in data
created: this.created,
progenitor: this.data.progenitor,
privacy: this.data.privacy,
proof,
Expand Down Expand Up @@ -357,7 +357,6 @@ export class ConversationStore {
const id = uuidv4()
const oldMessage: Message = { authorKey, content, hash: id, status: 'pending', timestamp: now, bucket, images}
this.addMessage(oldMessage)
// TODO: upload these images asynchonously and then add to the message when done
const imageStructs = await Promise.all(images.filter(i => !!i.file).map(async (image) => {
const hash = await this.fileStorageClient.uploadFile(image.file!)
return {
Expand Down
1 change: 0 additions & 1 deletion ui/src/store/RelayStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ export class RelayStore {

async createContact(contact: Contact) {
if (!this.client) return false
// TODO: if adding contact fails we should remove it from the store
const contactResult = await this.client.createContact(contact)
if (contactResult) {
// Immediately add a conversation with the new contact, unless you already have one with them
Expand Down

0 comments on commit e5bc308

Please sign in to comment.