Skip to content

즐겨찾기 기능 추가 PR #193

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

Merged
merged 8 commits into from
Mar 17, 2024
Merged

즐겨찾기 기능 추가 PR #193

merged 8 commits into from
Mar 17, 2024

Conversation

atawLee
Copy link
Contributor

@atawLee atawLee commented Mar 17, 2024

#82 즐겨찾기 기능 구현

image
image
위와 같이 즐겨찾기 기능을 추가했습니다.

SplashScreenLoadedCommand에서 json에 저장된 Favorite을 확인하여 Service 인스턴스에 추가로 부여합니다.

저장 기능은 CatalogPageItemFavoriteCommand를 위 favorite 버튼의 커맨드로 추가하였습니다.
위 커맨드 executeasync 에서 preferenceManager를 통해서 저장하는데, Json 저장시 길이가 짧아지는 경우 문제가 되어,
OpenOrWrite에서 Create로 변경하였습니다.

즐겨찾기만 보는 기능은 CatalogPageViewModel에 OnFavoriteOnly 프로퍼티를 추가하여, SetProperty 발생시
CatalogPageLoadedCommand를 통해서 CatalogInternetService의

public static bool IsMatchedItem(object item, string filterText, bool isFavoriteOnly)
{
    var actualItem = item as CatalogInternetService;

    if (actualItem == null)
        return false;

    if (isFavoriteOnly && !actualItem.IsFavorite)
        return false;

    if (string.IsNullOrWhiteSpace(filterText))
        return true;

    var result = false;
    var splittedFilterText = filterText.Split(FilterTextSeparators, StringSplitOptions.RemoveEmptyEntries);

    foreach (var eachFilterText in splittedFilterText)
    {
        result |= actualItem.DisplayName.IndexOf(eachFilterText, StringComparison.OrdinalIgnoreCase) > (-1)
                  || actualItem.CategoryDisplayName.IndexOf(eachFilterText, StringComparison.OrdinalIgnoreCase) > (-1)
                  || actualItem.Url.IndexOf(eachFilterText, StringComparison.OrdinalIgnoreCase) > (-1)
                  || actualItem.Packages.Count.ToString().IndexOf(eachFilterText, StringComparison.OrdinalIgnoreCase) > (-1)
                  || actualItem.Packages.Any(x => x.Name.IndexOf(eachFilterText, StringComparison.OrdinalIgnoreCase) > (-1))
                  || actualItem.Id.IndexOf(eachFilterText, StringComparison.OrdinalIgnoreCase) > (-1)
                  || actualItem.GetSearchKeywords().Any(x => x.IndexOf(eachFilterText, StringComparison.OrdinalIgnoreCase) > (-1));
    }

    return result;
}

메서드로 오버로드하여 구현하였습니다. (기존 IsMatchedItem은 MainWindowViewModel 쪽에서 사용하고 있어서 오버로드로 구현하였습니다.)

테스트 코드는 저장 부분 로직 우선적으로 작성하였고, 기능은 전반적으로 확인 하였습니다

@CLAassistant
Copy link

CLAassistant commented Mar 17, 2024

CLA assistant check
All committers have signed the CLA.

@rkttu rkttu merged commit dac4b3c into yourtablecloth:main Mar 17, 2024
@rkttu
Copy link
Member

rkttu commented Mar 17, 2024

@atawLee 오랫동안 진행하지 못한 요청 사항이었는데 시간 내어 contribution을 진행해주셔서 정말 감사드립니다!

@rkttu rkttu added this to the 1.3.0 milestone Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants