From 081251061d6fa55f2c4f2b6fb5abd3ff058706d4 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Mon, 28 Mar 2022 13:30:57 +0900 Subject: [PATCH] Library store refactor (#76) * start of music store refactor moving stuff into a state cache better separate it from view logic * added paginated list/album list * reworked fetchAlbumList to remove ui state refactored home screen to use new method i broke playing songs somehow, JS thread goes into a loop * don't reset parts manually, do it all at once * fixed perf issue related to too many rerenders rerenders were caused by strict equality check on object/array picks switched artistInfo to new store updated zustand and fixed deprecation warnings * update typescript and use workspace tsc version for vscode * remove old artistInfo * switched to new playlist w/songs removed more unused stuff * remove unused + (slightly) rework search * refactor star * use only original/large imges for covers/artist fix view artist from context menu add loading indicators to song list and artist views (show info we have right away) * set starred/unstar assuming it works and correct state on error * reorg, remove old music slice files * added back fix for song cover art * sort artists by localCompare name * update licenses * fix now playing background grey bar * update react-native-gesture-handler for node-fetch security alert * fix another gradient height grey bar issue * update licenses again * remove thumbnail cache * rename to remove "Library" from methods * Revert "remove thumbnail cache" This reverts commit e0db4931f11bbf4cd8e73102d06505c6ae85f4a6. * use ids for lists, pull state later * Revert "use only original/large imges for covers/artist" This reverts commit c9aea9065ce6ebe3c8b09c10dd74d4de153d76fd. * deep equal ListItem props for now this needs a bigger refactor * use immer as middleware * refactor api client to use string method hoping to use this for requestKey/deduping next * use thumbnails in list items * Revert "refactor api client to use string method" This reverts commit 234326135b7af96cb91b941e7ca515f45c632556. * rename/cleanup * store servers by id * get rid of settings selectors * renames for clarity remove unused estimateContentLength setting * remove trackplayer selectors * fix migration for library filter settings * fixed shuffle order reporting wrong track/queue * removed the other selectors * don't actually need es6/react for our state * fix slow artist sort on star localeCompare is too slow for large lists --- .vscode/settings.json | 3 + android/app/src/main/assets/licenses.html | 386 +++++++++++--- android/app/src/main/assets/licenses/npm.txt | 137 ++--- android/licenses.yml | 8 +- app/App.tsx | 5 +- app/components/BackgroundHeaderFlatList.tsx | 2 +- app/components/ContextMenu.tsx | 16 +- app/components/HeaderBar.tsx | 4 +- app/components/ListItem.tsx | 41 +- app/components/ListPlayerControls.tsx | 11 +- app/components/NowPlayingBar.tsx | 19 +- app/components/ProgressHook.tsx | 5 +- app/components/Star.tsx | 20 +- app/hooks/cache.ts | 37 +- app/hooks/library.ts | 63 +++ app/hooks/list.ts | 26 +- app/hooks/music.ts | 62 --- app/hooks/{server.ts => settings.ts} | 17 +- app/hooks/trackplayer.ts | 12 +- app/models/cache.ts | 4 +- app/models/{music.ts => library.ts} | 39 +- app/models/settings.ts | 20 - app/models/state.ts | 14 + app/models/trackplayer.ts | 18 + app/navigation/BottomTabBar.tsx | 7 +- app/navigation/BottomTabNavigator.tsx | 5 +- app/playbackservice.ts | 11 +- app/screens/ArtistView.tsx | 89 +++- app/screens/Home.tsx | 93 +++- app/screens/LibraryAlbums.tsx | 71 ++- app/screens/LibraryArtists.tsx | 25 +- app/screens/LibraryPlaylists.tsx | 16 +- app/screens/NowPlayingQueue.tsx | 10 +- app/screens/NowPlayingView.tsx | 52 +- app/screens/Search.tsx | 48 +- app/screens/SearchResultsView.tsx | 79 ++- app/screens/ServerView.tsx | 21 +- app/screens/Settings.tsx | 47 +- app/screens/SongListView.tsx | 94 +++- app/screens/SplashPage.tsx | 2 +- app/state/cache.ts | 178 +++---- app/state/library.ts | 521 +++++++++++++++++++ app/state/migrations.ts | 25 + app/state/music.ts | 471 ----------------- app/state/musicmap.ts | 142 ----- app/state/settings.ts | 204 +++----- app/state/store.ts | 137 +++-- app/state/trackplayer.ts | 184 +++---- app/state/trackplayermap.ts | 15 +- app/subsonic/api.ts | 93 ++-- app/subsonic/params.ts | 4 + app/subsonic/responses.ts | 232 +++++---- app/util/state.ts | 21 + index.js | 7 +- package.json | 11 +- tsconfig.json | 2 +- yarn.lock | 93 ++-- 57 files changed, 2136 insertions(+), 1843 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 app/hooks/library.ts delete mode 100644 app/hooks/music.ts rename app/hooks/{server.ts => settings.ts} (50%) rename app/models/{music.ts => library.ts} (51%) create mode 100644 app/models/state.ts create mode 100644 app/models/trackplayer.ts create mode 100644 app/state/library.ts delete mode 100644 app/state/music.ts delete mode 100644 app/state/musicmap.ts create mode 100644 app/util/state.ts diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..55712c1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} \ No newline at end of file diff --git a/android/app/src/main/assets/licenses.html b/android/app/src/main/assets/licenses.html index b21e89e..4b5d966 100644 --- a/android/app/src/main/assets/licenses.html +++ b/android/app/src/main/assets/licenses.html @@ -573,7 +573,7 @@
Copyright © Original Author. All rights reserved.
-http://developer.android.com/tools/extras/support-library.html
+https://developer.android.com/jetpack/androidx/releases/annotation#1.2.0
Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © Original Author. All rights reserved.
+https://developer.android.com/jetpack/androidx/releases/core#1.6.0
+ +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
++ "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. +
++ "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. +
++ "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. +
++ "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. +
++ "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. +
++ "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. +
++ "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). +
++ "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. +
++ "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." +
++ "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. +
++ Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. +
++ Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. +
++ You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: +
++ You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. +
++ Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. +
++ This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. +
++ Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. +
++ In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. +
++ While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +
+END OF TERMS AND CONDITIONS
++ To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. +
+Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.+