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

Support favorites #27

Open
shiqimei opened this issue Apr 2, 2023 · 0 comments
Open

Support favorites #27

shiqimei opened this issue Apr 2, 2023 · 0 comments
Labels
good first issue Good for newcomers

Comments

@shiqimei
Copy link
Contributor

shiqimei commented Apr 2, 2023

Background

Currently, BoardRecord has a property favorite labeings whether a board is favorited by a user, but this it not robust when we need to support multiple users later (a board is favorited by multiple users). We'd better use a new collection board_favorites to store such relationships.

Actions

  1. remove favorite key from BoardRecord, and all related stuff;
  2. add a new collection board_favorites, add a new file BoardFavoritesCollection in the models folder
  3. define inteface BoardFavoriteRecord
    interface {
      userId: string
      boardId: string
    }
  • when user starred a board, we add a new record to { userId, boardId } to board_favorites collection
  • when user unstarred a board, we remove this record
  • getFavoriteBoardsByUserId, is query { userId }
  1. Services & Subscriptions

4.1. add following public methods for clients to call

public starBoard(boardId: string): Promise<void> // we get userId with Meteor.userId() on server
public cancelStarBoard(boardId: string): Promise<void>
public getMineFavoriteBoards(): Promise<IBoard[]> // get favorite board ids in `board_favorites` and query boards in `boards`

4.2 add BoardFavoritesSubscriber to subscribe changes to board_favorites

4.3 add global atom states to update state in favorites sidebar and top right bar

sources

  1. filled star icon svg :
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" preserveAspectRatio="xMidYMid meet" class="" style="vertical-align: middle;"><g fill="currentColor"><path d="M8 0.350006C8.30049 0.350006 8.57286 0.526798 8.6952 0.801258L10.6192 5.11752L15.3187 5.61353C15.6176 5.64507 15.8699 5.84948 15.9627 6.13526C16.0556 6.42104 15.9716 6.73471 15.7484 6.93588L12.2379 10.0995L13.2184 14.7223C13.2808 15.0163 13.1643 15.3194 12.9212 15.496C12.6781 15.6726 12.3539 15.6897 12.0936 15.5396L8 13.1785L3.90643 15.5396C3.64614 15.6897 3.32187 15.6726 3.07877 15.496C2.83567 15.3194 2.71923 15.0163 2.78158 14.7223L3.76209 10.0995L0.251619 6.93588C0.0283977 6.73471 -0.0555759 6.42104 0.0372811 6.13526C0.130138 5.84948 0.382443 5.64507 0.681275 5.61353L5.38083 5.11752L7.3048 0.801258C7.42714 0.526798 7.69951 0.350006 8 0.350006Z"></path></g></svg>
  1. filled star icon color: #f0c000 (yellow)

  2. preview

    image
@shiqimei shiqimei added the good first issue Good for newcomers label Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant