~aleteoryx/muditaos

4804015a7012e7bdf8d9b58d4b5ae2260efa34d1 — Mateusz Piesta 3 years ago a83f714
[MOS-496] Music player broken UI

Fixed issues when selecting track index higher than 31.
M module-apps/apps-common/models/SongsRepository.cpp => module-apps/apps-common/models/SongsRepository.cpp +20 -7
@@ 86,9 86,9 @@ namespace app::music

    std::size_t SongsRepository::getCachedFileIndex(const std::string &filePath) const
    {
        auto it = std::find_if(musicFilesModelCache.records.begin(),
                               musicFilesModelCache.records.end(),
                               [filePath](const auto &musicFile) { return musicFile.fileInfo.path == filePath; });
        const auto it = std::find_if(musicFilesModelCache.records.begin(),
                                     musicFilesModelCache.records.end(),
                                     [filePath](const auto &musicFile) { return musicFile.fileInfo.path == filePath; });

        if (it != musicFilesModelCache.records.end()) {
            return std::distance(musicFilesModelCache.records.begin(), it);


@@ 97,6 97,20 @@ namespace app::music
        return std::numeric_limits<size_t>::max();
    }

    std::optional<db::multimedia_files::MultimediaFilesRecord> SongsRepository::getCachedViewEntryByFilePath(
        const std::string &filePath) const
    {
        const auto it = std::find_if(musicFilesViewCache.records.begin(),
                                     musicFilesViewCache.records.end(),
                                     [filePath](const auto &musicFile) { return musicFile.fileInfo.path == filePath; });

        if (it != musicFilesViewCache.records.end()) {
            return *it;
        }

        return std::nullopt;
    }

    std::string SongsRepository::getNextFilePath(const std::string &filePath) const
    {
        const auto currentIndex = getCachedFileIndex(filePath);


@@ 249,11 263,10 @@ namespace app::music
    std::optional<db::multimedia_files::MultimediaFilesRecord> SongsRepository::getRecord(
        const std::string &filePath) const
    {
        const auto index = getCachedFileIndex(filePath);
        if (index == std::numeric_limits<size_t>::max()) {
            return std::nullopt;
        if (const auto index = getCachedFileIndex(filePath); index != std::numeric_limits<size_t>::max()) {
            return musicFilesModelCache.records[index];
        }
        return musicFilesModelCache.records[index];
        return getCachedViewEntryByFilePath(filePath);
    }

} // namespace app::music

M module-apps/apps-common/models/SongsRepository.hpp => module-apps/apps-common/models/SongsRepository.hpp +4 -0
@@ 98,6 98,10 @@ namespace app::music
        std::size_t getCachedFileIndex(const std::string &filePath) const;
        std::uint32_t calculateOffset();

        /// Try to fetch list view's entry by the file name
        std::optional<db::multimedia_files::MultimediaFilesRecord> getCachedViewEntryByFilePath(
            const std::string &filePath) const;

        /// overwrite the musicFiles view cache with new data from the given index
        void updateMusicFilesList(std::uint32_t offset,
                                  std::uint32_t limit,

M pure_changelog.md => pure_changelog.md +1 -0
@@ 31,6 31,7 @@
* Fixed inactive alarms after timezone change and reboot.
* Fixed no sound when Bluetooth audio device connected/disconnected during call
* Fixed full filesystem path displayed in music player for invalid files instead of just filename
* Fixed problem with track info not being displayed correctly

### Added