-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Hide show more
btn in file-tree list if no more data
#24983
Conversation
show more
btn in file list if no more datashow more
btn in file-tree list if no more data
Lint fails:
|
@@ -94,6 +94,7 @@ export default { | |||
// Merge folders with just a folder as children in order to | |||
// reduce the depth of our tree. | |||
mergeChildIfOnlyOneDir(result); | |||
this.isIncomplete = pageData.diffFileInfo.isIncomplete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not change value in a computed
function. It breaks the reactive system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a use case for a store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup (not sure how to answer by yes or no, so see details)
For best practice: https://vuejs.org/guide/essentials/computed.html#best-practices
For "store": I think the page data should be passed by a store, this diff page has been broken for many times.
computed: { | ||
hasMore: { | ||
get() { | ||
return this.isIncomplete; | ||
}, | ||
set(newValue) { | ||
this.isIncomplete = newValue; | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you doing here .....
Why a "computed" property should be "set"?
Although Vue documents says writable-computed , but I do not think it is our case .....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key point of the problem here, it's not about "updating isIncomplete in computed property by tricks", the root problem is:
When the pageData.diffFileInfo
changes, it needs to "notify" the Vue component to update its data/properties.
The computed property
doesn't need to update anything, it should just provide the computed (read-only) result (Vue says: "Getters should be side-effect free ")
To make the Vue component could be notified by changed pageData.diffFileInfo
, either:
- Send an event to the Vue component after
pageData.diffFileInfo
is re-loaded, then Vue component re-read thepageData.diffFileInfo
to its internal reactive data/properties - Use "store" for
pageData.diffFileInfo
, then any change onpageData.diffFileInfo
will trigger the Vue's reactive system to sync the values.
I think "store" is the best practice here.
PR has valid open comments and changed completely in the meantime
This reverts commit 35422ca.
In #24956 I'm currently converting / trying to use the store from box.tmpl (to mark viewed files). If my solution for the store and box.tmpl is ok, then the show more button will work again, as this incomplete property is stored in the store, too. |
-> Refactor diffFileInfo / DiffTreeStore #24998 |
Follow #21012, #22399 Replace #24983, fix #24938 Help #24956 Now, the `window.config.pageData.diffFileInfo` itself is a reactive store, so it's quite easy to sync values/states by it, no need to do "doLoadMoreFiles" or "callback". Screenshot: these two buttons both work. After complete loading, the UI is also right. <details> ![image](https://github.com/go-gitea/gitea/assets/2114189/cc6310fd-7f27-45ea-ab4f-24952a87b421) ![image](https://github.com/go-gitea/gitea/assets/2114189/4c11dd67-ac03-4568-8541-91204d27a4e3) ![image](https://github.com/go-gitea/gitea/assets/2114189/38a22cec-41be-41e6-a209-f347b7a4c1de) </details>
replaced by #24998 |
fix #24938
Click
show more
btn in file-tree list:Screen.Recording.2023-05-29.at.18.22.00.mov
Click
show more
btn in file list:Screen.Recording.2023-05-29.at.18.56.17.mov