simplify timeline vibility checks
This commit is contained in:
parent
b92b2f74a4
commit
7e1b1e79f4
9 changed files with 59 additions and 26 deletions
23
src/lib/timeline_visibility.js
Normal file
23
src/lib/timeline_visibility.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const timelineVisibleUnauthenticated = (state, timeline) => (
|
||||
state.instance.publicTimelineVisibility[timeline] ?? false
|
||||
);
|
||||
|
||||
const currentUser = (state) => state.users.currentUser;
|
||||
|
||||
const currentUserOrTimelineVisibleUnauthenticated = (state, timeline) => (
|
||||
currentUser(state) || timelineVisibleUnauthenticated(state, timeline)
|
||||
);
|
||||
|
||||
const federatedTimelineAvailable = (state) => state.instance.federatedTimelineAvailable;
|
||||
|
||||
export const federatedTimelineVisible = (state) => (
|
||||
federatedTimelineAvailable(state) && currentUserOrTimelineVisibleUnauthenticated(state, 'federated')
|
||||
);
|
||||
|
||||
export const publicTimelineVisible = (state) => (
|
||||
currentUserOrTimelineVisibleUnauthenticated(state, 'local')
|
||||
);
|
||||
|
||||
export const bubbleTimelineVisible = (state) => (
|
||||
state.instance.localBubbleInstances.length > 0 && currentUserOrTimelineVisibleUnauthenticated(state, 'bubble')
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue