diff options
author | crupest <crupest@outlook.com> | 2021-01-21 20:00:29 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-21 20:00:29 +0800 |
commit | 545de7bcc3ac5e22da9761d7fbd0f85ce940415e (patch) | |
tree | 7c5cf7a2caebc4bbd898d472dbb88146e7a4f325 /FrontEnd/src/app/http/search.ts | |
parent | 24b944f1058bbd849953385e714f093021b406aa (diff) | |
download | timeline-545de7bcc3ac5e22da9761d7fbd0f85ce940415e.tar.gz timeline-545de7bcc3ac5e22da9761d7fbd0f85ce940415e.tar.bz2 timeline-545de7bcc3ac5e22da9761d7fbd0f85ce940415e.zip |
chore: Fix crlf.
Diffstat (limited to 'FrontEnd/src/app/http/search.ts')
-rw-r--r-- | FrontEnd/src/app/http/search.ts | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/FrontEnd/src/app/http/search.ts b/FrontEnd/src/app/http/search.ts index 8ff1c499..2da9295e 100644 --- a/FrontEnd/src/app/http/search.ts +++ b/FrontEnd/src/app/http/search.ts @@ -1,48 +1,48 @@ -import {
- apiBaseUrl,
- axios,
- convertToNetworkError,
- extractResponseData,
-} from "./common";
-import {
- HttpTimelineInfo,
- processRawTimelineInfo,
- RawHttpTimelineInfo,
-} from "./timeline";
-import { HttpUser } from "./user";
-
-export interface IHttpSearchClient {
- searchTimelines(query: string): Promise<HttpTimelineInfo[]>;
- searchUsers(query: string): Promise<HttpUser[]>;
-}
-
-export class HttpSearchClient implements IHttpSearchClient {
- searchTimelines(query: string): Promise<HttpTimelineInfo[]> {
- return axios
- .get<RawHttpTimelineInfo[]>(`${apiBaseUrl}/search/timelines?q=${query}`)
- .then(extractResponseData)
- .then((ts) => ts.map(processRawTimelineInfo))
- .catch(convertToNetworkError);
- }
-
- searchUsers(query: string): Promise<HttpUser[]> {
- return axios
- .get<HttpUser[]>(`${apiBaseUrl}/search/users?q=${query}`)
- .then(extractResponseData)
- .catch(convertToNetworkError);
- }
-}
-
-let client: IHttpSearchClient = new HttpSearchClient();
-
-export function getHttpSearchClient(): IHttpSearchClient {
- return client;
-}
-
-export function setHttpSearchClient(
- newClient: IHttpSearchClient
-): IHttpSearchClient {
- const old = client;
- client = newClient;
- return old;
-}
+import { + apiBaseUrl, + axios, + convertToNetworkError, + extractResponseData, +} from "./common"; +import { + HttpTimelineInfo, + processRawTimelineInfo, + RawHttpTimelineInfo, +} from "./timeline"; +import { HttpUser } from "./user"; + +export interface IHttpSearchClient { + searchTimelines(query: string): Promise<HttpTimelineInfo[]>; + searchUsers(query: string): Promise<HttpUser[]>; +} + +export class HttpSearchClient implements IHttpSearchClient { + searchTimelines(query: string): Promise<HttpTimelineInfo[]> { + return axios + .get<RawHttpTimelineInfo[]>(`${apiBaseUrl}/search/timelines?q=${query}`) + .then(extractResponseData) + .then((ts) => ts.map(processRawTimelineInfo)) + .catch(convertToNetworkError); + } + + searchUsers(query: string): Promise<HttpUser[]> { + return axios + .get<HttpUser[]>(`${apiBaseUrl}/search/users?q=${query}`) + .then(extractResponseData) + .catch(convertToNetworkError); + } +} + +let client: IHttpSearchClient = new HttpSearchClient(); + +export function getHttpSearchClient(): IHttpSearchClient { + return client; +} + +export function setHttpSearchClient( + newClient: IHttpSearchClient +): IHttpSearchClient { + const old = client; + client = newClient; + return old; +} |