Skip to content

refactor(tasks): refactor tasks store #76

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

Merged
merged 20 commits into from
Sep 3, 2024
Merged

Conversation

QZera
Copy link
Collaborator

@QZera QZera commented Jun 10, 2024

Closes e0dbc12

@QZera QZera added the enhancement New feature extending the app's current capabilities label Jun 10, 2024
@QZera QZera requested a review from maninak June 10, 2024 05:44
@QZera QZera self-assigned this Jun 10, 2024
Copy link

netlify bot commented Jun 10, 2024

Deploy Preview for chipper-wisp-c7553e ready!

Name Link
🔨 Latest commit caa02cf
🔍 Latest deploy log https://app.netlify.com/sites/chipper-wisp-c7553e/deploys/66d754bbc9541e0008263f0c
😎 Deploy Preview https://deploy-preview-76--chipper-wisp-c7553e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@QZera QZera force-pushed the feat/e0dbc12_refactor-tasks-store branch from 47eed6c to 0c009f3 Compare June 15, 2024 14:24
Copy link
Collaborator

@maninak maninak left a comment

Choose a reason for hiding this comment

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

I think this PR is on the right track. Well done on the introduction of vue-query too! 👏

Some of the topics we mentioned in the sync repo review (e.g. co-location of use-tasks-fetch, null vs undefined, etc) I've mostly omitted for this PR but of course feel free to begin applying them with this one or make a full repo-wide approach approach later.

@QZera QZera force-pushed the feat/e0dbc12_refactor-tasks-store branch from 0c009f3 to c101f6a Compare August 7, 2024 06:20
Copy link
Collaborator Author

@QZera QZera left a comment

Choose a reason for hiding this comment

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

Thanks for the feedback!

Some of the applied changes went beyond the scope of the commented line. You can have a look at the corresponding commit to get the full picture.

I didn't refactor the topics mentioned in the sync in this PR since I didn't want to increase the scope. I will address those in a separate PR.

@QZera QZera requested a review from maninak August 12, 2024 04:52
QZera added 17 commits September 3, 2024 08:45
…store

- Introduced the use-mutation composable to abstract common mutation logic
- Refactored task store actions to utilize the use-mutation composable

Signed-off-by: Zacharias Fragkiadakis <[email protected]>
- Refactored `moveTask` into 2 functions:
  - `optimisticallyUpdateTasksPositions`: optimistically updates tasks' priorities and columns
  based on provided parameters
  - `moveTask`: given a task, a column and an index, calculates the which tasks need to be updated
  and how, and calls optimisticallyUpdateTasksPositions

- Refactored `refreshSpecificTasks` since it wasn't working properly with the aforementioned
changes

- Renamed some functions in `useTasksFetch` for better clarity

Signed-off-by: Zacharias Fragkiadakis <[email protected]>
- Added a computed property to keep track of tasks without a priority
- Updated the logic of when `initializePriority` is called to rely on the computed property
rather than only run once after the tasks are fetched
- Refactored `initializePriority`:
  - to use the computed property
  - to refresh all tasks on settled rather than only on success

Signed-off-by: Zacharias Fragkiadakis <[email protected]>
- Refactored `resetPriority` to not make PATCH calls to update each task, instead, only update the
local state of the tasks. This still triggers `initializePriority`, yielding the same result fo
half the requests.
- Updated `Reset Order` button:
  - it no longer indicates `resetPriority` is in progress as it is now synchronous
  - it now uses the same styles as the rest of the app's buttons

Signed-off-by: Zacharias Fragkiadakis <[email protected]>
- Updated `initializePriority` to assign priorities to tasks without priority based on the highest
priority in their respective columns

Signed-off-by: Zacharias Fragkiadakis <[email protected]>
Signed-off-by: Zacharias Fragkiadakis <[email protected]>
@QZera QZera force-pushed the feat/e0dbc12_refactor-tasks-store branch from c101f6a to f87c5b4 Compare September 3, 2024 06:25
Copy link
Collaborator

@maninak maninak left a comment

Choose a reason for hiding this comment

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

Well done, Zac! 👏

At some point, it may be worth covering some mission-critical store functions etc with tests too, but given that this is a refactoring PR and a long-standing one too, best to be tackled separately. We can talk about this with the PM.

If this approval becomes stale when fixing the CI issues and you need a re-review in a pinch don't hesitate to ping me on zulip.

@maninak maninak removed the enhancement New feature extending the app's current capabilities label Sep 3, 2024
@maninak maninak added the chore Tooling or infra-related, not directly affecting core product label Sep 3, 2024
Use said function to enforce switch switch statements handle all possible values

Signed-off-by: Zacharias Fragkiadakis <[email protected]>
@QZera QZera force-pushed the feat/e0dbc12_refactor-tasks-store branch from f87c5b4 to caa02cf Compare September 3, 2024 18:26
@QZera QZera merged commit f49b056 into main Sep 3, 2024
10 checks passed
@QZera QZera deleted the feat/e0dbc12_refactor-tasks-store branch September 3, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Tooling or infra-related, not directly affecting core product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants