Правка и очистка
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using Knot.Shared.Kernel.Configuration;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Host.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ConfigController : ControllerBase
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Knot.Modules.Chats;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Knot.Modules.Identity;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Knot.Shared.Infrastructure;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Knot.Shared.Kernel;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
@@ -81,7 +81,11 @@ export default function EmojiPicker({ onSelect, onSelectGif, onClose }: EmojiPic
|
||||
}, [tab, klipyApiKey, klipyCustomerId]);
|
||||
|
||||
const searchGifs = useCallback((q: string) => {
|
||||
if (!klipyApiKey || !q.trim()) { setGifs([]); return; }
|
||||
if (!klipyApiKey || !q.trim()) {
|
||||
setGifs([]);
|
||||
setGifLoading(false);
|
||||
return;
|
||||
}
|
||||
setGifLoading(true);
|
||||
fetch(`https://api.klipy.com/api/v1/${klipyApiKey}/gifs/search?page=1&per_page=30&q=${encodeURIComponent(q)}&customer_id=${klipyCustomerId}`)
|
||||
.then(async (r) => {
|
||||
|
||||
@@ -419,6 +419,7 @@ export default function MessageInput({ chatId }: MessageInputProps) {
|
||||
fileSize: result.size
|
||||
}],
|
||||
replyToId: replyTo?.id || null,
|
||||
quote: replyTo?.quote || null,
|
||||
});
|
||||
setReplyTo(null);
|
||||
}
|
||||
@@ -882,6 +883,7 @@ export default function MessageInput({ chatId }: MessageInputProps) {
|
||||
fileSize: 0,
|
||||
}],
|
||||
replyToId: replyTo?.id || null,
|
||||
quote: replyTo?.quote || null,
|
||||
});
|
||||
setReplyTo(null);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,10 @@ class ApiClient {
|
||||
return this.request<{ user: User }>('/auth/me');
|
||||
}
|
||||
|
||||
async getConfig() {
|
||||
return this.request<any>('/config');
|
||||
}
|
||||
|
||||
// \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438
|
||||
async searchUsers(query: string) {
|
||||
return this.request<UserPresence[]>(`/users/search?q=${encodeURIComponent(query)}`);
|
||||
|
||||
@@ -25,11 +25,10 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
config: null,
|
||||
|
||||
fetchConfig: async () => {
|
||||
if (!get().token) return;
|
||||
try {
|
||||
const res = await fetch('/api/config');
|
||||
if (res.ok) {
|
||||
set({ config: await res.json() });
|
||||
}
|
||||
const res = await api.getConfig();
|
||||
set({ config: res });
|
||||
} catch {}
|
||||
},
|
||||
|
||||
@@ -41,6 +40,7 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
api.setToken(token);
|
||||
connectSocket(token);
|
||||
set({ token, user, isLoading: false });
|
||||
await get().fetchConfig();
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
set({ error: msg, isLoading: false });
|
||||
@@ -56,6 +56,7 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
api.setToken(token);
|
||||
connectSocket(token);
|
||||
set({ token, user, isLoading: false });
|
||||
await get().fetchConfig();
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
set({ error: msg, isLoading: false });
|
||||
@@ -71,7 +72,6 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
},
|
||||
|
||||
checkAuth: async () => {
|
||||
get().fetchConfig();
|
||||
const token = get().token;
|
||||
if (!token) {
|
||||
set({ isLoading: false });
|
||||
@@ -86,6 +86,7 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
const { user } = await api.getMe();
|
||||
connectSocket(token);
|
||||
set({ user, isLoading: false });
|
||||
await get().fetchConfig();
|
||||
return;
|
||||
} catch (err) {
|
||||
lastError = err;
|
||||
|
||||
Reference in New Issue
Block a user