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