Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// ==================== APP BOOTSTRAP ====================

function setScreenVisibility({ showAuth }) {
const splash = document.getElementById('splash');
const authScreen = document.getElementById('auth-screen');
const mainApp = document.getElementById('main-app');

if (splash) splash.classList.add('hidden');

if (showAuth) {
authScreen?.classList.remove('hidden');
mainApp?.classList.add('hidden');
} else {
authScreen?.classList.add('hidden');
mainApp?.classList.remove('hidden');
}
}

function safelyRunAuthListener() {
if (typeof auth === 'undefined' || !auth?.onAuthStateChanged) {
setScreenVisibility({ showAuth: true });
return;
}

auth.onAuthStateChanged((user) => {
if (user) {
currentUser = user;
setScreenVisibility({ showAuth: false });
} else {
setScreenVisibility({ showAuth: true });
}
}, () => {
setScreenVisibility({ showAuth: true });
});
}

function registerFallbacks() {
window.app = window.app || {
toggleSidebar() {
toast?.show('Sidebar coming soon', 'info');
}
};

window.nav = window.nav || {
openMessages() {
toast?.show('Messages coming soon', 'info');
}
};

window.camera = window.camera || {
open() {
toast?.show('Camera coming soon', 'info');
}
};

window.story = window.story || {
add() {
toast?.show('Stories coming soon', 'info');
}
};
}

function hideSplashAfterDelay() {
const splash = document.getElementById('splash');
if (!splash) return;

setTimeout(() => {
splash.classList.add('hidden');
}, 1200);
}

window.addEventListener('DOMContentLoaded', () => {
registerFallbacks();
hideSplashAfterDelay();
});

window.addEventListener('load', () => {
safelyRunAuthListener();
});
19 changes: 5 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

<!-- Styles -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="style.css">
</head>
<body class="bg-black text-white overflow-hidden theme-purple" id="app-body">

Expand Down Expand Up @@ -406,19 +406,10 @@ <h3 class="text-sm font-bold text-gray-500 uppercase tracking-wider mb-3">Accoun
</div>

<!-- ==================== SCRIPTS ==================== -->
<script src="js/firebase.js"></script>
<script src="js/utils.js"></script>
<script src="js/auth.js"></script>
<script src="js/app.js"></script>
<script src="js/feed.js"></script>
<script src="js/camera.js"></script>
<script src="js/comments.js"></script>
<script src="js/stories.js"></script>
<script src="js/chat.js"></script>
<script src="js/friends.js"></script>
<script src="js/profile.js"></script>
<script src="js/settings.js"></script>
<script src="js/admin.js"></script>
<script src="firebase.js"></script>
<script src="utils.js"></script>
<script src="auth.js"></script>
<script src="app.js"></script>
Comment on lines 408 to +412

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep module scripts or stub all referenced handlers

The script list now loads only firebase.js, utils.js, auth.js, and app.js, but the HTML still wires many actions to globals such as settings.open(), messages.switchTab(), chat.send(), comments.post(), profile.edit(), etc. (see the onclick handlers throughout index.html, e.g., around lines 329–339, 287–310). Without the removed module scripts (e.g., settings.js, chat.js, comments.js), those globals are never defined, so the first user interaction will throw ReferenceError and leave the UI unresponsive for those flows. If the intent is to trim scripts, you’ll need fallback stubs for all referenced modules or to remove/disable the corresponding handlers in the HTML.

Useful? React with 👍 / 👎.


</body>
</html>