Merge pull request #5 from ArnasDon/perf/use-get-session-client-side

perf: use getSession() instead of getUser() in client components
This commit is contained in:
Arnas Donauskas 2026-04-16 20:06:11 +03:00 committed by GitHub
commit aaaddf0d5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 30 additions and 22 deletions

View File

@ -25,8 +25,9 @@ export default function InboxPage() {
const checkConnection = async () => {
const supabase = createClient();
const {
data: { user },
} = await supabase.auth.getUser();
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
if (!user) return;

View File

@ -85,8 +85,9 @@ export default function PipelinesPage() {
setCreating(true);
const {
data: { user },
} = await supabase.auth.getUser();
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
if (!user) {
setCreating(false);
return;

View File

@ -223,8 +223,9 @@ export function ContactDetailView({
setSavingNote(true);
const {
data: { user },
} = await supabase.auth.getUser();
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
if (!user) {
toast.error('Not authenticated');
setSavingNote(false);

View File

@ -87,8 +87,9 @@ export function ContactForm({
try {
const {
data: { user },
} = await supabase.auth.getUser();
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
if (!user) throw new Error('Not authenticated');
let contactId = contact?.id;

View File

@ -123,8 +123,9 @@ export function ImportModal({ open, onOpenChange, onImported }: ImportModalProps
try {
const {
data: { user },
} = await supabase.auth.getUser();
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
if (!user) throw new Error('Not authenticated');
let imported = 0;

View File

@ -84,8 +84,9 @@ export function ContactSidebar({ contact }: ContactSidebarProps) {
const supabase = createClient();
const {
data: { user },
} = await supabase.auth.getUser();
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
const { data, error } = await supabase
.from("contact_notes")

View File

@ -96,8 +96,9 @@ export function DealForm({
await supabase.from("deals").update(payload).eq("id", deal.id);
} else {
const {
data: { user },
} = await supabase.auth.getUser();
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
if (user) {
await supabase
.from("deals")

View File

@ -92,8 +92,9 @@ export function PipelineSettings({
async function handleAddStage() {
if (!newStageName.trim()) return;
const {
data: { user },
} = await supabase.auth.getUser();
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
if (!user) return;
const { data } = await supabase

View File

@ -49,7 +49,7 @@ export function TagManager() {
async function fetchTags() {
try {
setLoading(true);
const { data: { user } } = await supabase.auth.getUser();
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
if (!user) return;
const { data, error } = await supabase
@ -76,7 +76,7 @@ export function TagManager() {
try {
setSaving(true);
const { data: { user } } = await supabase.auth.getUser();
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
if (!user) {
toast.error('Not authenticated');
return;

View File

@ -77,7 +77,7 @@ export function TemplateManager() {
async function fetchTemplates() {
try {
setLoading(true);
const { data: { user } } = await supabase.auth.getUser();
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
if (!user) return;
const { data, error } = await supabase
@ -108,7 +108,7 @@ export function TemplateManager() {
try {
setSaving(true);
const { data: { user } } = await supabase.auth.getUser();
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
if (!user) {
toast.error('Not authenticated');
return;

View File

@ -56,7 +56,7 @@ export function WhatsAppConfig() {
async function fetchConfig() {
try {
setLoading(true);
const { data: { user } } = await supabase.auth.getUser();
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
if (!user) return;
const { data, error } = await supabase
@ -97,7 +97,7 @@ export function WhatsAppConfig() {
try {
setSaving(true);
const { data: { user } } = await supabase.auth.getUser();
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
if (!user) {
toast.error('Not authenticated');
return;