             }
         }
         
-        self.completionCallbacks[identifier] = nil
-    }
-}
+        self.completionCallbacks[callbackKey] = nil
+    }
+}

            }
        }
        
        self.completionCallbacks[identifier] = nil
    }
    
    private func invokeFailureCallbacksForIdentifier(_ identifier: String, error: Error) {
        guard let callbacks = completionCallbacks[identifier] else {
            return
        }
        

    
    static let sharedManager = VoiceMessageAttachmentCacheManager()
    
    private var completionCallbacks = [CompletionCallbackKey: [CompletionWrapper]]()
    private var samples = [String: [Int: [Float]]]()
    private var durations = [String: TimeInterval]()
    private var finalURLs = [String: URL]()
    
    private let workQueue: DispatchQueue
    
    private init() {
        workQueue = DispatchQueue(label: "io.element.VoiceMessageAttachmentCacheManager.queue", qos: .userInitiated)
    }
    
    func loadAttachment(_ attachment: MXKAttachment, numberOfSamples: Int, completion: @escaping (Result<VoiceMessageAttachmentCacheManagerLoadResult, Error>) -> Void) {
