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

Copy card: "show as thumb" attachment setting is not cloned #5364

Open
e-gaulue opened this issue Apr 2, 2024 · 2 comments
Open

Copy card: "show as thumb" attachment setting is not cloned #5364

e-gaulue opened this issue Apr 2, 2024 · 2 comments

Comments

@e-gaulue
Copy link
Contributor

e-gaulue commented Apr 2, 2024

Server Setup Information

  • Did you test in newest Wekan?: Yes
  • Did you configure root-url correctly so Wekan cards open correctly (see https://github.com/wekan/wekan/wiki/Settings)? Yes
  • Operating System: Bookworm
  • Deployment Method (Snap/Docker/Sandstorm/bundle/source): Snap release
  • Http frontend if any (Caddy, Nginx, Apache, see config examples from Wekan GitHub wiki first): Apache
  • Node.js Version: wekan snap
  • MongoDB Version: mongodb snap
  • What webbrowser version are you using (Wekan should work on all modern browsers that support Javascript)? Firefox ESR

Problem description

Reproduction Steps

Clone a board, open it, image are not shown in cards. Look at board setting and check if thumbs are set to be shown: it is. Go on the card and request attachment to be shown and it appears. So it's just this information that hasn't been "copied".

Other

That's not a major trouble as we use clone to archive board. I'll try to look at it in the code if I get the time.

@e-gaulue
Copy link
Contributor Author

I may be wrong but I think the trouble code is there:

wekan/models/cards.js

Lines 587 to 593 in e73a44d

const _id = Cards.insert(this);
// Copy attachments
oldCard.attachments()
.forEach(att => {
copyFile(att, _id, fileStoreStrategyFactory);
});

When a card is inserted, there may be a control that disable this option to show 'attachements' if the card has no attachment. then attachment are created in the next block. But then should try a Cards.update(this) or something more sweet/targeted that retry to set this setting.

@e-gaulue
Copy link
Contributor Author

@xet7

OK, I got it.

When the card is inserted, the coverId key of the new card points to the previous attachment file _id.

When attachments have been copied, one should look for the _id of the new card new attachments whose key "meta.copyFrom" is equal to the current coverId key. Then, change this key, with this _id.

The trouble is copyFile is async. The best would be copyFile to return the _id of the new attachment in a Promise, and to wait for this Promise only for the copy of the cover attachment. I didn't go further because it would imply waiting, and I know wekan is really concerned with scalability (copying a board means possibly copying a lot of cards).

Another way would be copyFile to handle this coverId change when called from the copy card function... Sounds strange...

We could also consider, the situation completely differently and handle it at display time. If coverId points to an attachment not belonging to the current card, look for current card attachments whose "meta.copyFrom" is equal to the current coverId and then correct it. This should be efficient. And if not enough, we could add a flag on the new card after copy to trigger this only once, but I think this is needless. When displaying a card anyway, the Card object is built with all the data we need, and it's no more than a condition test.

Your opinions?

@e-gaulue e-gaulue changed the title Clone board: "show as thumb" attachment setting is not cloned Copy card: "show as thumb" attachment setting is not cloned May 16, 2024
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

No branches or pull requests

1 participant