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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ dependencies {
implementation(libs.ktor.client.cio)
implementation(libs.ktor.server.core)
implementation(libs.ktor.server.cio)
implementation(libs.ktor.server.websockets)
implementation(libs.ktor.client.websockets)

implementation(libs.ktor.server.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
implementation(libs.ktor.client.content.negotiation)
Expand All @@ -160,6 +163,7 @@ dependencies {
implementation(libs.ktor.client.android)
implementation(libs.androidx.work.runtime.ktx)
implementation(libs.androidx.documentfile)
implementation(project(":shared"))

// Add Firebase dependencies to pro and freePlayStore flavors specifically
"proImplementation"(platform(libs.firebase.bom))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.yogeshpaliyal.deepr.analytics

import android.content.Context
import com.yogeshpaliyal.shared.analytics.AnalyticsManager
import com.yogeshpaliyal.shared.analytics.AnalyticsManagerFactory

object AnalyticsManagerFactoryImpl : AnalyticsManagerFactory {
override fun create(context: Context): AnalyticsManager = NoOpAnalyticsManager()
override fun create(): AnalyticsManager = NoOpAnalyticsManager()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.yogeshpaliyal.deepr.analytics

import com.yogeshpaliyal.shared.analytics.AnalyticsManager

class NoOpAnalyticsManager : AnalyticsManager {
override fun logEvent(
eventName: String,
Expand Down
101 changes: 96 additions & 5 deletions app/src/main/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,83 @@ <h3 class="text-xl font-semibold text-gray-700 mb-2">Loading links...</h3>
<script>
// Global variables to store all links and available tags
let allLinks = [];
let availableTags = []; // Now contains {id, name, count} objects
let selectedTags = []; // Now contains {id, name} objects
let availableTags = [];
let selectedTags = [];
let linksSocket = null;
let reconnectTimer = null;
let hasConnectedToSocket = false;
const WS_RETRY_MS = 5000;

// WebSocket connection management
function connectLinksWebSocket() {
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
const wsUrl = `${protocol}://${window.location.host}/ws/updates`;

try {
linksSocket?.close();
linksSocket = new WebSocket(wsUrl);
} catch (error) {
console.error('Unable to create websocket', error);
scheduleSocketReconnect();
return;
}

linksSocket.addEventListener('open', () => {
hasConnectedToSocket = true;
if (reconnectTimer) {
clearTimeout(reconnectTimer);
reconnectTimer = null;
}
showToast('Live updates enabled', 'info');
});

linksSocket.addEventListener('message', (event) => handleSocketMessage(event.data));

linksSocket.addEventListener('close', () => {
if (hasConnectedToSocket) {
showToast('Live updates disconnected. Retrying...', 'error');
}
scheduleSocketReconnect();
});

linksSocket.addEventListener('error', () => {
linksSocket?.close();
});
}

function handleSocketMessage(rawData) {
try {
const parsed = JSON.parse(rawData);
switch(parsed.dataType){
case 'links_list':
allLinks = parsed.links;
populateTagFilter();
filterAndDisplayLinks();
break;
default:
console.warn('Unknown dataType received from websocket:', parsed.dataType);
}
} catch (error) {
console.error('Failed parsing websocket payload', error);
}
}

function scheduleSocketReconnect() {
if (reconnectTimer) {
return;
}
reconnectTimer = setTimeout(() => {
reconnectTimer = null;
connectLinksWebSocket();
}, WS_RETRY_MS);
}

function disconnectWebSocket() {
if (websocket) {
websocket.close();
websocket = null;
Comment on lines +343 to +345
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

The function references websocket variable, but the code uses linksSocket as the variable name. This should be linksSocket to match the actual WebSocket variable being used throughout the file.

Suggested change
if (websocket) {
websocket.close();
websocket = null;
if (linksSocket) {
linksSocket.close();
linksSocket = null;

Copilot uses AI. Check for mistakes.
}
}

// Toast notification system
function showToast(message, type = 'success') {
Expand Down Expand Up @@ -676,7 +751,13 @@ <h3 class="text-xl font-semibold text-gray-700 mb-2">Error loading links</h3>
tagsInput.value = '';
selectedTags = [];
updateSelectedTagsDisplay();
loadLinks();

// If WebSocket is not connected, fallback to HTTP
if (!websocket || websocket.readyState !== WebSocket.OPEN) {
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

References undefined websocket variable instead of linksSocket. Should use linksSocket to check WebSocket connection state.

Suggested change
if (!websocket || websocket.readyState !== WebSocket.OPEN) {
if (!linksSocket || linksSocket.readyState !== WebSocket.OPEN) {

Copilot uses AI. Check for mistakes.
loadLinks();
}
// Otherwise, WebSocket will automatically send updated data

loadAvailableTags();

button.innerHTML = `
Expand Down Expand Up @@ -764,12 +845,22 @@ <h3 class="text-xl font-semibold text-gray-700 mb-2">Error loading links</h3>

// Form and refresh
document.getElementById('addLinkForm').addEventListener('submit', addLink);
document.getElementById('refreshBtn').addEventListener('click', loadLinks);
document.getElementById('refreshBtn').addEventListener('click', function() {
if (websocket && websocket.readyState === WebSocket.OPEN) {
showToast('Using real-time connection', 'info');
} else {
connectLinksWebSocket();
}
});
Comment on lines +848 to +854
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

References undefined websocket variable instead of linksSocket. Should use linksSocket to check WebSocket connection state.

Copilot uses AI. Check for mistakes.

// Initialize
updateSortOrderIcon();
loadLinks();
loadAvailableTags();
connectLinksWebSocket();
});

window.addEventListener('beforeunload', () => {
linksSocket?.close();
});
</script>
</body>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/yogeshpaliyal/deepr/DeeprApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.yogeshpaliyal.deepr.backup.ExportRepository
import com.yogeshpaliyal.deepr.backup.ExportRepositoryImpl
import com.yogeshpaliyal.deepr.backup.ImportRepository
import com.yogeshpaliyal.deepr.backup.ImportRepositoryImpl
import com.yogeshpaliyal.deepr.data.DataProvider
import com.yogeshpaliyal.deepr.data.HtmlParser
import com.yogeshpaliyal.deepr.data.NetworkRepository
import com.yogeshpaliyal.deepr.preference.AppPreferenceDataStore
Expand Down Expand Up @@ -133,6 +134,10 @@ class DeeprApplication : Application() {
ReviewManagerFactory.create()
}

single<DataProvider> {
DataProvider(get())
}

viewModel {
TransferLinkLocalServerViewModel(get())
}
Expand Down
99 changes: 2 additions & 97 deletions app/src/main/java/com/yogeshpaliyal/deepr/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ import com.yogeshpaliyal.deepr.ui.screens.home.Dashboard2
import com.yogeshpaliyal.deepr.ui.screens.home.TagSelectionScreen
import com.yogeshpaliyal.deepr.ui.theme.DeeprTheme
import com.yogeshpaliyal.deepr.util.LanguageUtil
import com.yogeshpaliyal.shared.data.SharedLink
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.runBlocking

data class SharedLink(
val url: String,
val title: String?,
)


class MainActivity : ComponentActivity() {
val sharingLink = MutableStateFlow<SharedLink?>(null)
Expand Down Expand Up @@ -132,96 +130,3 @@ class MainActivity : ComponentActivity() {
}
}

private val TOP_LEVEL_ROUTES: List<TopLevelRoute> =
listOf(Dashboard2(), TagSelectionScreen, Settings)

val LocalSharedText =
compositionLocalOf<Pair<SharedLink?, () -> Unit>?> { null }

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Dashboard(
modifier: Modifier = Modifier,
sharedText: SharedLink? = null,
resetSharedText: () -> Unit,
) {
val backStack =
remember {
TopLevelBackStack<BaseScreen>(
Dashboard2(),
)
}
val current = backStack.getLast()
val scrollBehavior = BottomAppBarDefaults.exitAlwaysScrollBehavior()
val hapticFeedback = LocalHapticFeedback.current
val layoutDirection = LocalLayoutDirection.current

CompositionLocalProvider(LocalSharedText provides Pair(sharedText, resetSharedText)) {
CompositionLocalProvider(LocalNavigator provides backStack) {
Scaffold(
modifier = modifier,
bottomBar = {
AnimatedVisibility(
(TOP_LEVEL_ROUTES.any { it::class == current::class }),
enter = slideInVertically(initialOffsetY = { it }),
exit = slideOutVertically(targetOffsetY = { it }),
) {
BottomAppBar(scrollBehavior = scrollBehavior) {
TOP_LEVEL_ROUTES.forEach { topLevelRoute ->
val isSelected =
topLevelRoute::class == backStack.topLevelKey::class
NavigationBarItem(
selected = isSelected,
onClick = {
hapticFeedback.performHapticFeedback(HapticFeedbackType.ContextClick)
backStack.addTopLevel(topLevelRoute)
},
label = {
Text(stringResource(topLevelRoute.label))
},
icon = {
Icon(
imageVector = topLevelRoute.icon,
contentDescription = null,
)
},
)
}
}
}
},
) { contentPadding ->
NavDisplay(
backStack = backStack.backStack,
entryDecorators =
listOf(
// Add the default decorators for managing scenes and saving state
rememberSceneSetupNavEntryDecorator(),
rememberSavedStateNavEntryDecorator(),
// Then add the view model store decorator
rememberViewModelStoreNavEntryDecorator(),
),
onBack = {
backStack.removeLast()
},
entryProvider = {
NavEntry(it) { entryItem ->
if (entryItem is TopLevelRoute) {
entryItem.Content(
WindowInsets(
left = contentPadding.calculateLeftPadding(layoutDirection),
right = contentPadding.calculateRightPadding(layoutDirection),
top = contentPadding.calculateTopPadding(),
bottom = contentPadding.calculateBottomPadding(),
),
)
} else if (entryItem is Screen) {
entryItem.Content()
}
}
},
)
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class CsvBookmarkImporter(
val tagsString = row.getOrNull(5) ?: ""
val thumbnail = row.getOrNull(6) ?: ""
val isFavourite = row.getOrNull(7)?.toLongOrNull() ?: 0
val existing = deeprQueries.getDeeprByLink(link).executeAsOneOrNull()
if (link.isNotBlank() && existing == null) {
val existing = deeprQueries.isLinkExists(link).executeAsOneOrNull() ?: 0L
if (link.isNotBlank() && existing == 0L) {
updatedCount++
deeprQueries.transaction {
deeprQueries.importDeepr(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ abstract class HtmlBookmarkImporter(
val bookmarks = extractBookmarks(document)

bookmarks.forEach { bookmark ->
val existing = deeprQueries.getDeeprByLink(bookmark.url).executeAsOneOrNull()
if (bookmark.url.isNotBlank() && existing == null) {
val existing = deeprQueries.isLinkExists(bookmark.url).executeAsOneOrNull()
if (bookmark.url.isNotBlank() && existing == 0L) {
try {
deeprQueries.transaction {
deeprQueries.insertDeepr(
Expand All @@ -38,6 +38,7 @@ abstract class HtmlBookmarkImporter(
name = bookmark.title,
notes = bookmark.folder ?: "",
thumbnail = "",
isFavourite = 0
)

// Add tags if present
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/yogeshpaliyal/deepr/data/DBtoDataAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.yogeshpaliyal.deepr.data

import com.yogeshpaliyal.deepr.GetLinksAndTags
import com.yogeshpaliyal.shared.data.DeeprLink

fun GetLinksAndTags.toDeeprLink(): DeeprLink {
return DeeprLink(
id = this.id,
link = this.link,
name = this.name,
createdAt = this.createdAt,
openedCount = this.openedCount,
isFavourite = this.isFavourite,
notes = this.notes,
thumbnail = this.thumbnail,
lastOpenedAt = this.lastOpenedAt,
tagsNames = this.tagsNames,
tagsIds = this.tagsIds,
tags = this.tagsNames?.split(",")?.filter { it.isNotEmpty() } ?: emptyList(),
)
}
Loading