Various fixes

This commit is contained in:
Ilya Laktyushin
2023-09-02 19:02:53 +04:00
parent 5992236a25
commit 1c455e4fec
6 changed files with 229 additions and 61 deletions

View File

@@ -219,7 +219,7 @@ public func addStoryDraft(engine: TelegramEngine, item: MediaEditorDraft) {
public func removeStoryDraft(engine: TelegramEngine, path: String, delete: Bool) {
if delete {
try? FileManager.default.removeItem(atPath: fullDraftPath(engine: engine, path: path))
try? FileManager.default.removeItem(atPath: fullDraftPath(peerId: engine.account.peerId, path: path))
}
let itemId = MediaEditorDraftItemId(path.persistentHashValue)
let _ = engine.orderedLists.removeItem(collectionId: ApplicationSpecificOrderedItemListCollectionId.storyDrafts, id: itemId.rawValue).start()
@@ -270,10 +270,10 @@ public func updateStoryDrafts(engine: TelegramEngine) {
public extension MediaEditorDraft {
func fullPath(engine: TelegramEngine) -> String {
return fullDraftPath(engine: engine, path: self.path)
return fullDraftPath(peerId: engine.account.peerId, path: self.path)
}
}
func fullDraftPath(engine: TelegramEngine, path: String) -> String {
return NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] + "/storyDrafts_\(engine.account.peerId.toInt64())/" + path
func fullDraftPath(peerId: EnginePeer.Id, path: String) -> String {
return NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] + "/storyDrafts_\(peerId.toInt64())/" + path
}