Skip to content

[Enhancement] Share/Send multiple links with/to Linkora (android) #150#151

Open
linky3754 wants to merge 1 commit into
LinkoraApp:masterfrom
linky3754:enhancement/150-share-send-multiple-links-with-to-linkora
Open

[Enhancement] Share/Send multiple links with/to Linkora (android) #150#151
linky3754 wants to merge 1 commit into
LinkoraApp:masterfrom
linky3754:enhancement/150-share-send-multiple-links-with-to-linkora

Conversation

@linky3754

Copy link
Copy Markdown
Contributor

Addresses #150

Comment on lines +905 to +968
if(numUrls == 1){
performAction(
AddANewLinkDialogBoxAction.AddANewLink(
link = Link(
linkType = linkType,
title = titleTextFieldValue.value.trim(),
url = linkTextFieldValue.value.trim(),
imgURL = imgUrlTextFieldValue.value.trim(),
note = noteTextFieldValue.value,
idOfLinkedFolder = currentFolder?.localId
?: selectedFolderForSavingTheLink.value.localId,
userAgent = preferences.primaryJsoupUserAgent
),
linkSaveConfig = LinkSaveConfig(
forceAutoDetectTitle = isAutoDetectTitleEnabled.value || preferences.isAutoDetectTitleForLinksEnabled,
forceSaveWithoutRetrievingData = isForceSaveWithoutFetchingMetaDataEnabled.value || preferences.forceSaveWithoutFetchingAnyMetaData,
useProxy = preferences.useProxy,
skipSavingIfExists = preferences.skipSavingExistingLink,
forceSaveIfRetrievalFails = preferences.forceSaveIfRetrievalFails
),
onCompletion = onDismiss,
selectedTags = selectedTags,
pushSnackbarOnSuccess = true
)
)
)
}
else {
for (linkTextField in splitLinkTextFieldValue) {
if (linkTextField == "") {
continue;
}

var extractedUrls = extractUrls(linkTextField)

for (extractedUrl in extractedUrls) {
var url = extractedUrl.trim()

performAction(
AddANewLinkDialogBoxAction.AddANewLink(
link = Link(
linkType = linkType,
title = titleTextFieldValue.value.trim(),
url = url,
imgURL = imgUrlTextFieldValue.value.trim(),
note = noteTextFieldValue.value,
idOfLinkedFolder = currentFolder?.localId
?: selectedFolderForSavingTheLink.value.localId,
userAgent = preferences.primaryJsoupUserAgent
),
linkSaveConfig = LinkSaveConfig(
forceAutoDetectTitle = false,
forceSaveWithoutRetrievingData = true,
useProxy = preferences.useProxy,
skipSavingIfExists = preferences.skipSavingExistingLink,
forceSaveIfRetrievalFails = preferences.forceSaveIfRetrievalFails
),
onCompletion = onDismiss,
selectedTags = selectedTags,
pushSnackbarOnSuccess = true
)
)
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should have a function in linksRepo (e.g., insertLinks or addLinks) which accepts multiple links and the LinkSaveConfig similar to the existing function, and all of the processing related to these links must happen there in a single shot instead of looping through individual links here.

so in LocalLinksRepoImpl, we can change the existing function that saves a single link into something that does the above operation.

we should take all those links and validate in this repository implementation, once we are sure about the valid ones, we can launch all the html scraping tasks in background for these valid links, i.e., via async {} since we need the result of the scrapeLinkData/retrieveFromVxTwitterApi or retrieveFromProxy if proxy usage is enabled.

once we got those results, we can insert all these with one operation via multi insert query, but since room already supports multi-insert, you can directly use addMultipleLinks

and we need the ids of the rows that are inserted to update the remote ids once we complete the remote operations for these links that we ofc get from the addMultipleLinks.

also we can use the size of the list returned by addMultipleLinks to show how many links are validated and saved.


if you also want to do the remote implementation for this, then loop through the results and send requests to the server, since there is no endpoint that accepts multiple links at once (which is bad, i'll add support to that later) we gotta do individually. we do need this operation, but if you're not interested in it, i'll add that when i get the time, so we can have the feature working completely :)

Comment on lines +160 to +185
var sharedUrls = this@ShareToSaveActivity.intent?.getStringExtra(
Intent.EXTRA_TEXT
).toString().lines();

var url = ""
var title = ""

if(sharedUrls.size > 1) {
var urlStringForDialogBox = sharedUrls[0].toString()

for (i in 1 until sharedUrls.size) {
urlStringForDialogBox += "\n\n"
urlStringForDialogBox += sharedUrls[i].toString()
}

url = urlStringForDialogBox
preferences.forceSaveWithoutFetchingAnyMetaData = true
}else{
url = this@ShareToSaveActivity.intent?.getStringExtra(
Intent.EXTRA_TEXT
).toString()
title = this@ShareToSaveActivity.intent?.getStringExtra(
Intent.EXTRA_SUBJECT
) ?: ""
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should pass the text as-is and we need to parse the links here, instead of AddANewLink, we need something that accepts the raw text from our UI, so in here we use the extractUrls and forward the links to the function that accepts multiple links (see: https://github.com/LinkoraApp/Linkora/pull/151/changes#r3409815977) in the linksRepo


so we should keep whatever we previously had in AddANewLinkDialogBox as-is:

url = this@ShareToSaveActivity.intent?.getStringExtra(
    Intent.EXTRA_TEXT
).toString(),
title = this@ShareToSaveActivity.intent?.getStringExtra(
    Intent.EXTRA_SUBJECT
) ?: ""

val showHostInLinkListView: Boolean = true,
val enableFadedEdgeForNonListViews: Boolean = true,
val forceSaveWithoutFetchingAnyMetaData: Boolean = false,
var forceSaveWithoutFetchingAnyMetaData: Boolean = false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since we will fetch the info from the webpage properly, we don't need this "hack", and even in general, this is not a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants