NEAR-DevHub / neardevhub-contract

DevHub Portal Product Contract (Hosted on NEAR Blockchain) – Includes other instances (e.g. Infrastructure, Events)
https://neardevhub.org
19 stars 15 forks source link

Fix panic when adding first post #15

Closed ailisp closed 1 year ago

ailisp commented 1 year ago

When a developer deploy devgigsboard to his account and try to add a post for the first time, it hits this panic:

        let mut siblings = self
            .post_to_children
            .get(&parent_id)
            .unwrap_or_else(|| panic!("Parent id {} not found", parent_id));

This PR fixes this corner case and preserve the logic for the other cases.

frol commented 1 year ago

@ailisp Have you considered initializing the parent post in the new function? I feel it will be more reliable that way and clear from maintenance point of view.

ailisp commented 1 year ago

@frol Yes that sounds better