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

Sub-sub-collection based on another state #210

Open
jaytonic opened this issue Jul 16, 2021 · 1 comment
Open

Sub-sub-collection based on another state #210

jaytonic opened this issue Jul 16, 2021 · 1 comment

Comments

@jaytonic
Copy link

jaytonic commented Jul 16, 2021

Hi,

I'm doing a free "scrum planning" tool, mostly to learn about akita, firebase and angular while still doing something usefull, in order to check if this is the framework I want to push at my work for our next angular app.

I will have the following structure on firebase:

/rooms/{roomId}/
			   /activeStoryId
			   /stories/{storyId}/
								 /storyDescription
								 /votes/{voteId}/
												/value
												/voter
								 /storyStats

So, currently, I've a RoomsStore. I've an ActiveRoomGuard that sync the active room when I navigate to "https://hostname/rooms/{id}".

I'm currently creating a parallel StoriesStore( based on your subcollection here: https://github.com/dappsnation/akita-ng-fire/blob/v6/src/app/subcollection/stakeholder.guard.ts ), for which I should also do an ActiveStoryGuard. But I'm not sure how to implement this. Is it possible to use the RoomsQuery to get the activeStoryId of the active room? How?

I don't want to have the Id of the story in the URL because I don't want users to be able to navigate between the stories(there will be another vue to have an overview of the past estimations) and I want to have everybody that is on the same room with the same view.

Here is my current status:

@Injectable({ providedIn: 'root' })
@CollectionGuardConfig({ awaitSync: true })
export class ActiveStoryGuard extends CollectionGuard<StoriesState> {
  constructor(service: StoriesService) {
    super(service);
  }

  // Sync and set active
  sync(next: ActivatedRouteSnapshot) {
    const { id } = next.params;
    //How to retrieve the story ID?
    return this.service.syncActive(
      { id: storyId },
      { params: { roomId: id } }
    );
  }
}

Thank you very much for your valued support.

@randallmeeker
Copy link
Collaborator

You can use RoomsQuery inside this, same as any service. I think the question that is un answered is where you activeStoryId is being held.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants