Skip to content

Comments

timeline group/sort and more#17

Open
arminakvn wants to merge 18 commits intomainfrom
aa/groupAttrPropSwitch
Open

timeline group/sort and more#17
arminakvn wants to merge 18 commits intomainfrom
aa/groupAttrPropSwitch

Conversation

@arminakvn
Copy link
Member

@arminakvn arminakvn commented Mar 3, 2025

  • upgraded dependencies to latest versions,
  • updated the esbuild's build config: added commonJS, fixed the peer dependency external packages,
  • fixed the package.json file to include exports paths for both commonJS and ESM.
  • added framer-motion and update the codebase to use motion transitions etc.
  • fixed the group by method to use the attrProp object to look at the values of the field it will need to group the blocks by.
  • added a center block method
  • added a computed method to indicate if the timeline blocks are out of sort in the blocks store.
  • implement sort by group and default sort mechanisms.
  • fixed how the context is shared with the client, i.e. optional context prop, as well as initially using the useTimeline

@arminakvn arminakvn marked this pull request as ready for review March 7, 2025 15:51
@arminakvn arminakvn changed the title DRAFT timeline group/sort timeline group/sort and more Mar 7, 2025
}
}
}, [block, blocks]);
}, [block, blocks,timeline.blocks.selected]);
Copy link
Member

Choose a reason for hiding this comment

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

why is the dependency not just block.selected?

Copy link
Member Author

@arminakvn arminakvn Mar 7, 2025

Choose a reason for hiding this comment

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

nice finding this took me so much to figure out.... so, it turned out in timeline, we can't simply expose the timeline context with the useTimeline... this because since we are having two context, one for timeline and another for the block itself, what happens is if the client, say in dashi, the user closes the timeline layout and say switches the layout to another layout, then after returning to the timeline layout, the two context go out of sync, because technically the block context won't exit with the timeline layout closing.... so my solution was this....

blck.setGroupName(blck[this.groupBy])
reslt[blck[this.groupBy]] = [blck]
@computed
get blockYIndecies() {
Copy link
Member

Choose a reason for hiding this comment

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

fix typo

return (a_first_block > b_first_block) ? 1 : -1
}).sort()

const overGroups = overSortedGroups.reduce((res, groupKey, i, allGroups) => {
Copy link
Member

Choose a reason for hiding this comment

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

generally I sould suggest avoiding large monolithic functions like this and breaking it down. If you break this down so that each of these larger variables is a computed property on the store, it looks cleaner, is more readable and you get the advantage that mobx will memoize the structure so that any changes only trigger recalculations where needed

if (this.customSpaces) this.customSpaces.forEach((cs)=>{
Object.keys(cs).forEach((k,i)=>{
const time_span = cs[k]
Object.keys(cs['spaces']).forEach((k,i)=>{
Copy link
Member

Choose a reason for hiding this comment

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

probably need a check for undefined here

context.blocks.setAsSorted();
}
}
}, [context.blocks, groupBy, groupByFieldName]);

Choose a reason for hiding this comment

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

since groupByFieldName is a ref, can it trigger the useEffect here?

@george-yihao-xu
Copy link

Another thought, I think it will be beneficial to have storybook here to make the testing easier. Agree? So u dont need to connect to dashi app, right?

let grppRes = 0;
const grpd = this.all.reduce((reslt, blck) => {
if (Object.keys(reslt).includes(blck.attrProps[this.groupBy])) {
reslt[blck.attrProps[this.groupBy]].push(blck)
Copy link
Member

Choose a reason for hiding this comment

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

small thing. fix typo - blck

@tadiraman
Copy link
Member

No need to change in this PR. One thing we need to discuss as a team is to use correctly spelled variables. Exceptions can be new names or terms specific to a client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants