finished implementing history with removal options
This commit is contained in:
+28
@@ -69,4 +69,32 @@ class GeckoHistoryApiImpl() : GeckoHistoryApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteVisit(
|
||||
url: String,
|
||||
timestamp: Long,
|
||||
callback: (Result<Unit>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.historyStorage.deleteVisit(url, timestamp);
|
||||
|
||||
callback(Result.success(Unit))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteVisitsBetween(
|
||||
startMillis: Long,
|
||||
endMillis: Long,
|
||||
callback: (Result<Unit>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.historyStorage.deleteVisitsBetween(startMillis, endMillis);
|
||||
|
||||
callback(Result.success(Unit))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -4750,6 +4750,8 @@ interface GeckoDeleteBrowsingDataController {
|
||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||
interface GeckoHistoryApi {
|
||||
fun getDetailedVisits(startMillis: Long, endMillis: Long, excludeTypes: List<VisitType>, callback: (Result<List<VisitInfo>>) -> Unit)
|
||||
fun deleteVisit(url: String, timestamp: Long, callback: (Result<Unit>) -> Unit)
|
||||
fun deleteVisitsBetween(startMillis: Long, endMillis: Long, callback: (Result<Unit>) -> Unit)
|
||||
|
||||
companion object {
|
||||
/** The codec used by GeckoHistoryApi. */
|
||||
@@ -4782,6 +4784,46 @@ interface GeckoHistoryApi {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoHistoryApi.deleteVisit$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val urlArg = args[0] as String
|
||||
val timestampArg = args[1] as Long
|
||||
api.deleteVisit(urlArg, timestampArg) { result: Result<Unit> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(null))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoHistoryApi.deleteVisitsBetween$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val startMillisArg = args[0] as Long
|
||||
val endMillisArg = args[1] as Long
|
||||
api.deleteVisitsBetween(startMillisArg, endMillisArg) { result: Result<Unit> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(null))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,15 @@ class GeckoHistoryService {
|
||||
VisitType.values.toSet().difference(types).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteVisit(VisitInfo info) {
|
||||
return _api.deleteVisit(info.url, info.visitTime);
|
||||
}
|
||||
|
||||
Future<void> deleteVisitsBetween(DateTime start, DateTime end) {
|
||||
return _api.deleteVisitsBetween(
|
||||
start.millisecondsSinceEpoch,
|
||||
end.millisecondsSinceEpoch,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5731,6 +5731,52 @@ class GeckoHistoryApi {
|
||||
return (pigeonVar_replyList[0] as List<Object?>?)!.cast<VisitInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteVisit(String url, int timestamp) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoHistoryApi.deleteVisit$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[url, timestamp]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteVisitsBetween(int startMillis, int endMillis) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoHistoryApi.deleteVisitsBetween$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[startMillis, endMillis]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoDownloadsApi {
|
||||
|
||||
@@ -1248,6 +1248,12 @@ abstract class GeckoHistoryApi {
|
||||
int endMillis,
|
||||
List<VisitType> excludeTypes,
|
||||
);
|
||||
|
||||
@async
|
||||
void deleteVisit(String url, int timestamp);
|
||||
|
||||
@async
|
||||
void deleteVisitsBetween(int startMillis, int endMillis);
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
|
||||
Reference in New Issue
Block a user