Skip to content

Commit d9230ba

Browse files
authored
fix: remove anon login, it won't be supported for now (#185)
🎫 Ticket: https://linear.app/stream/issue/REACT-691/remove-anon-support πŸ“‘ Docs: N/A ### πŸ’‘ Overview ### πŸ“ Implementation notes
1 parent dbcb708 commit d9230ba

File tree

4 files changed

+13
-106
lines changed

4 files changed

+13
-106
lines changed

β€Žpackages/feeds-client/__integration-tests__/anonymous-user.test.tsβ€Ž

Lines changed: 0 additions & 61 deletions
This file was deleted.

β€Žpackages/feeds-client/__integration-tests__/websocket-connection.test.tsβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ describe('WebSocket connection', () => {
2525
connected_user: undefined,
2626
is_ws_connection_healthy: false,
2727
own_capabilities_by_fid: {},
28-
is_anonymous: false,
2928
},
3029
undefined,
3130
);

β€Žpackages/feeds-client/src/bindings/react/hooks/useCreateFeedsClient.tsβ€Ž

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,14 @@ import {
1212
export const useCreateFeedsClient = ({
1313
apiKey,
1414
tokenOrProvider,
15-
userData: userDataOrAnonymous,
15+
userData,
1616
options,
1717
}: {
1818
apiKey: string;
19-
tokenOrProvider?: TokenOrProvider;
20-
userData: UserRequest | 'anonymous';
19+
tokenOrProvider: TokenOrProvider;
20+
userData: UserRequest;
2121
options?: FeedsClientOptions;
2222
}) => {
23-
const userData =
24-
userDataOrAnonymous === 'anonymous' ? undefined : userDataOrAnonymous;
25-
26-
if (userDataOrAnonymous === 'anonymous' && !tokenOrProvider) {
27-
throw new Error(
28-
'Token provider can only be emitted when connecting anonymous user',
29-
);
30-
}
31-
3223
const [client, setClient] = useState<FeedsClient | null>(
3324
() => new FeedsClient(apiKey, options),
3425
);
@@ -41,23 +32,21 @@ export const useCreateFeedsClient = ({
4132
throw error;
4233
}
4334

44-
if (userData?.id !== cachedUserData?.id) {
35+
if (userData.id !== cachedUserData.id) {
4536
setCachedUserData(userData);
4637
}
4738

4839
useEffect(() => {
4940
const _client = new FeedsClient(apiKey, cachedOptions);
5041

51-
const connectionPromise = cachedUserData
52-
? _client
53-
.connectUser(cachedUserData, tokenOrProvider)
54-
.then(() => {
55-
setError(null);
56-
})
57-
.catch((err) => {
58-
setError(err);
59-
})
60-
: _client.connectAnonymous();
42+
const connectionPromise = _client
43+
.connectUser(cachedUserData, tokenOrProvider)
44+
.then(() => {
45+
setError(null);
46+
})
47+
.catch((err) => {
48+
setError(err);
49+
});
6150

6251
setClient(_client);
6352

β€Žpackages/feeds-client/src/feeds-client/feeds-client.tsβ€Ž

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ import { getFeed } from '../activity-with-state-updates/get-feed';
9393

9494
export type FeedsClientState = {
9595
connected_user: ConnectedUser | undefined;
96-
is_anonymous: boolean;
9796
is_ws_connection_healthy: boolean;
9897
own_capabilities_by_fid: Record<string, FeedResponse['own_capabilities']>;
9998
};
@@ -137,7 +136,6 @@ export class FeedsClient extends FeedsApi {
137136
super(apiClient);
138137
this.state = new StateStore<FeedsClientState>({
139138
connected_user: undefined,
140-
is_anonymous: false,
141139
is_ws_connection_healthy: false,
142140
own_capabilities_by_fid: {},
143141
});
@@ -393,25 +391,7 @@ export class FeedsClient extends FeedsApi {
393391
this.state.partialNext({ own_capabilities_by_fid: ownCapabilitiesCache });
394392
}
395393

396-
connectAnonymous = () => {
397-
this.connectionIdManager.resolveConnectionidPromise();
398-
this.tokenManager.setTokenOrProvider(undefined);
399-
this.setGetBatchOwnCapabilitiesThrottlingInterval(
400-
this.query_batch_own_capabilties_throttling_interval,
401-
);
402-
this.state.partialNext({
403-
connected_user: undefined,
404-
is_anonymous: true,
405-
is_ws_connection_healthy: false,
406-
});
407-
408-
return Promise.resolve();
409-
};
410-
411-
connectUser = async (
412-
user: UserRequest | { id: '!anon' },
413-
tokenProvider?: TokenOrProvider,
414-
) => {
394+
connectUser = async (user: UserRequest, tokenProvider?: TokenOrProvider) => {
415395
if (
416396
this.state.getLatestValue().connected_user !== undefined ||
417397
this.wsConnection

0 commit comments

Comments
Β (0)