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

sorting: its not working lol #45

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

sorting: its not working lol #45

wants to merge 30 commits into from

Conversation

ashlsun
Copy link
Owner

@ashlsun ashlsun commented Jul 11, 2024

the placement of the sorting select input is just temporary - could imagine this just being moved into a settings box or be something like cickable table headings on a grid layout, like spotify

anyway i was just trying to see if i could get it to work but . i don't think i fully understand svelte reactivity cause i initially just tried to mutate list and changed it to this when it wasn't visibly updating anything. it still doesn't visibly update 😞
this is the error i got
after switching to "a to z" Screenshot 2024-07-10 at 11 45 51 PM

i wonder what a proxy array / object is & why its not just a regular list?
im also finding it interesting that this null error comes after sorting and assigning. is it happening somewhere in the components?

@Rettend
Copy link
Collaborator

Rettend commented Jul 11, 2024

i did a major refactor and changed some behaviors a little:

  • adding an already existing item now increments the quantity
  • this also fixes adding random items when they are full
  • when selecting items with the up/down arrows, it now jumps between storages upon reaching the edge

ideas for further improvs:

  • add a small delay when pressing down the up/down arrow keys, it currently navigates so fast you can't see it
  • use numbers and maybe ctrl to quickly navigate between storages. like ctrl + 1 to select the first item of the first storage, ctrl + 2 to select the second storage's first item (oh ctrl + a number already jumps between tabs in the browser so we would need different shortcuts or maybe override the broswer's?)
  • fix sorting aaaaaa

@ashlsun
Copy link
Owner Author

ashlsun commented Jul 12, 2024

noticing:

  • if a user is visiting for the first time (if nothing is in the db) there are no storage places on the screen. i think it would be nice to display an empty fridge and empty freezer
  • item count doesn't update
  • sorting is sorta working?? just sorts according to the previously chosen sortBy
  • previously, deleting the last item in a storage place set the new last item as the selected, which i think would be nice to keep!
  • previously, entering a new item will unselect any selected item in the storage place, now it stays selected

hmm and i am having trouble reproducing this, but there was a moment upon first loading when pressing enter would not add an item (the input text would disappear but the item would not be created)! i'll keep my eyes peeled if it happens again

@ashlsun
Copy link
Owner Author

ashlsun commented Jul 12, 2024

i love the wrapping to the next storage when reaching the edge tho 🤩

@ashlsun
Copy link
Owner Author

ashlsun commented Jul 12, 2024

i thought it might make more sense to just have the parsing happen in StoragePlace instead of the store, which avoids the add/import naming confusion

@Rettend Rettend marked this pull request as draft July 12, 2024 13:19
@ashlsun
Copy link
Owner Author

ashlsun commented Jul 12, 2024

wondering why sorting is non responsive and then works after a little bit for me
https://github.com/user-attachments/assets/b23cc3da-2189-455d-96a3-0d60623b4c73

nvm!! might have been the item.name as id

@ashlsun
Copy link
Owner Author

ashlsun commented Jul 12, 2024

ok so i added an apple just now, and then i updated its dateAdded to be 14d ago. when sorting by newest it should be the middle item, but it seems like it still treats it as the newest
https://github.com/user-attachments/assets/d8159a9c-933d-42fd-91e5-f0c01a235295

might also make sense to start with sort by: none at first, and then if a sort by option is selected, any changes to any of the items in the relevant attributes might cause them to be resorted

@Rettend
Copy link
Collaborator

Rettend commented Jul 12, 2024

ok so i added an apple just now, and then i updated its dateAdded to be 14d ago. when sorting by newest it should be the middle item, but it seems like it still treats it as the newest https://github.com/user-attachments/assets/d8159a9c-933d-42fd-91e5-f0c01a235295

might also make sense to start with sort by: none at first, and then if a sort by option is selected, any changes to any of the items in the relevant attributes might cause them to be resorted

i could not reproduce that bug you had, but added the 'none' sort option. when adding a new item it switches to none, but this does not work when adding random items (debug feature anyway)

@Rettend
Copy link
Collaborator

Rettend commented Jul 12, 2024

how about this?
image

a text x wouldn't be bad either but cant really increase the font size, or the gap between them grows too:
image

Rettend added 3 commits July 12, 2024 19:34
* item count was not reactive, can't make $derived value with parameter so a record of itemCounts was created
* fixed: tests that used text="delete" broke after swapping it to an icon
@Rettend
Copy link
Collaborator

Rettend commented Jul 12, 2024

  • use flexbox on storages, row wrap for desktop. col for mobile

@@ -23,7 +23,10 @@ export default {
customise: (content, name, prefix) => {
switch (prefix) {
case 'tabler':
return content.replaceAll('stroke-width="2"', 'stroke-width="3"')
if (name === 'x')
Copy link
Collaborator

Choose a reason for hiding this comment

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

wow nice

if (!storages.includes(storage)) {
storages.push(storage)
items[storage] = []
await db.foodItems.where('storage').equals(storage).toArray()
Copy link
Owner Author

Choose a reason for hiding this comment

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

is the result of this supposed to be stored anywhere?

Copy link
Collaborator

@Rettend Rettend Jul 17, 2024

Choose a reason for hiding this comment

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

hm no that can be removed it seems, no need to query there. i'm still not 100% sure how dexie works

@ashlsun
Copy link
Owner Author

ashlsun commented Jul 18, 2024

huh! pulled the latest updates and encountered this bug where clicking on an item in the 1st storage place ended up selecting an item in 2nd one. after that error, clicking anything else stops working 😮

Screen.Recording.2024-07-17.at.10.30.20.PM.mov

i tried going back one commit at a time, and it seems like the bug doesnt happen until after c02e645, refactor: change sort dropdown handling for tests? checking out 8e6ac1b and running the app, clicking on items seems to work as expected

its the removal of untrack, isnt it?

@Rettend
Copy link
Collaborator

Rettend commented Jul 18, 2024

huh! pulled the latest updates and encountered this bug where clicking on an item in the 1st storage place ended up selecting an item in 2nd one. after that error, clicking anything else stops working 😮

Screen.Recording.2024-07-17.at.10.30.20.PM.mov
i tried going back one commit at a time, and it seems like the bug doesnt happen until after c02e645, refactor: change sort dropdown handling for tests? checking out 8e6ac1b and running the app, clicking on items seems to work as expected

its the removal of untrack, isnt it?

ah sryyyy, it was untrack.

@ashlsun ashlsun marked this pull request as ready for review October 17, 2024 21:47
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.

2 participants