Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: delete no longer relevant todo comments, commented out code #192

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion dnas/relay/zomes/coordinator/relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pub mod contact;
pub mod message;
pub mod config;
pub mod ping;
// pub mod utils;
use hdk::prelude::*;
use relay_integrity::*;

Expand Down
79 changes: 3 additions & 76 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 Expand Up @@ -212,7 +139,7 @@ pub fn get_latest_message(
}
None => original_message_hash.clone(),
};
// get(latest_message_hash, GetOptions::default())

match get(latest_message_hash, GetOptions::default())? {
Some(record) => {
Ok(Some(MessageRecord {
Expand Down
2 changes: 0 additions & 2 deletions dnas/relay/zomes/integrity/relay/src/contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ pub fn validate_create_link_all_contacts(
.to_string())
),
)?;
// TODO: add the appropriate validation rules
Ok(ValidateCallbackResult::Valid)
}

Expand All @@ -172,6 +171,5 @@ pub fn validate_delete_link_all_contacts(
_target: AnyLinkableHash,
_tag: LinkTag,
) -> ExternResult<ValidateCallbackResult> {
// TODO: add the appropriate validation rules
Ok(ValidateCallbackResult::Valid)
}
2 changes: 0 additions & 2 deletions dnas/relay/zomes/integrity/relay/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub fn validate_create_link_all_messages(
.to_string())
),
)?;
// TODO: add the appropriate validation rules
Ok(ValidateCallbackResult::Valid)
}
pub fn validate_delete_link_all_messages(
Expand All @@ -134,6 +133,5 @@ pub fn validate_delete_link_all_messages(
_target: AnyLinkableHash,
_tag: LinkTag,
) -> ExternResult<ValidateCallbackResult> {
// TODO: add the appropriate validation rules
Ok(ValidateCallbackResult::Valid)
}
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
4 changes: 1 addition & 3 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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already is in the invitation data? Or am I missing something?

created: this.created,
progenitor: this.data.progenitor,
privacy: this.data.privacy,
proof,
Expand Down Expand Up @@ -220,7 +220,6 @@ export class ConversationStore {
}

get title() {
// TODO: when invited contacts is stored in HC this can go back to invitedContactKeys
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I don't understand at all.

const numInvited = this.allMembers.length
if (this.data?.privacy === Privacy.Public) {
return this.data?.config.title
Expand Down Expand Up @@ -357,7 +356,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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already implemented, unless I misunderstood.

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contact is only added to the store once successful;

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