mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
b46bf91575
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added AI feature consent flow requiring user agreement before enabling AI capabilities. * Added calendar integration support including CalDAV account linking and management. * Expanded workspace administration capabilities with detailed workspace analytics and configuration options. * **Improvements** * Enhanced workspace sharing and configuration controls. * Added support for calendar provider presets and subscriptions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
45 lines
1.4 KiB
Swift
45 lines
1.4 KiB
Swift
//
|
|
// AffineViewController+AIButton.swift
|
|
// App
|
|
//
|
|
// Created by 秋星桥 on 2025/1/8.
|
|
//
|
|
|
|
import Intelligents
|
|
import UIKit
|
|
|
|
extension AFFiNEViewController: IntelligentsButtonDelegate {
|
|
private static let aiConsentKey = "com.affine.intelligents.userConsented"
|
|
|
|
private var hasUserConsented: Bool {
|
|
UserDefaults.standard.bool(forKey: Self.aiConsentKey)
|
|
}
|
|
|
|
func onIntelligentsButtonTapped(_: IntelligentsButton) {
|
|
if hasUserConsented {
|
|
presentIntelligentsController()
|
|
return
|
|
}
|
|
showAIConsentAlert()
|
|
}
|
|
|
|
private func presentIntelligentsController() {
|
|
let controller = IntelligentsController()
|
|
present(controller, animated: true)
|
|
}
|
|
|
|
private func showAIConsentAlert() {
|
|
let alert = UIAlertController(
|
|
title: "AI Feature Data Usage",
|
|
message: "To provide AI-powered features, your input (such as document content and conversation messages) will be sent to a third-party AI service for processing. This data is used solely to generate responses and is not used for any other purpose.\n\nBy continuing, you agree to share this data with the AI service.",
|
|
preferredStyle: .alert
|
|
)
|
|
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
|
|
alert.addAction(UIAlertAction(title: "Agree & Continue", style: .default) { [weak self] _ in
|
|
UserDefaults.standard.set(true, forKey: Self.aiConsentKey)
|
|
self?.presentIntelligentsController()
|
|
})
|
|
present(alert, animated: true)
|
|
}
|
|
}
|