Ignore:
Timestamp:
2021-09-20T15:13:08+12:00 (3 years ago)
Author:
cstephen
Message:

Prevent duplicate transcriptions being created

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/main.js

    r35430 r35432  
    33import App from "./App.vue";
    44import ToggleButton from "./components/ToggleButton.vue"
    5 import Util from "./js/Util"
    65
    76export class TranscriptionViewModel {
     
    1413    constructor(transcription, file) {
    1514        /** @type {String} The UUID of this transcription. */
    16         this.id = Util.generateUuid();
     15        this.id = file.name + file.size + file.type; // Should be a fairly reliable indicator of uniqueness.
    1716
    1817        /** @type {String} The transcription. */
     
    5352}
    5453
     54export class TranscriptionExistsError extends Error {
     55    constructor(message = "", ...args) {
     56        super(message, ...args);
     57    }
     58}
     59
    5560const store = createStore({
    5661    state() {
     
    7075         */
    7176        transcriptionAdd(state, transcription) {
     77            if (state.rawTranscriptions.has(transcription.id)) {
     78                throw new Error("Transcription already exists");
     79            }
    7280            state.rawTranscriptions.set(transcription.id, transcription);
    7381        },
Note: See TracChangeset for help on using the changeset viewer.