decord/source/stores/UploadAttachmentStore.tsx

351 lines
9.6 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 4741
// Function ID: 4742
2026-07-29 08:29:29 +00:00
// Name: map
2026-08-25 06:04:03 +00:00
// Dependencies: [4742, 676, 4744, 1236, 12, 4953, 4961, 589, 709, 2]
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 4741 (map)
2026-08-24 06:08:38 +00:00
import set from "set" /* 2 */;
import initializeDefault from "initialize" /* 589 */;
import ME from "ME" /* 676 */;
import dispatcherDefault from "dispatcher" /* 709 */;
2026-08-25 06:04:03 +00:00
import handleChanged from "handleChanged" /* 4742 */;
import set2 from "set" /* 4953 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
const DraftType = handleChanged.DraftType;
const MAX_UPLOAD_COUNT = ME.MAX_UPLOAD_COUNT;
2026-07-29 08:29:29 +00:00
let map = new Map();
let closure_6 = [];
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class UploadAttachmentStore extends Store {
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = UploadAttachmentStore.prototype;
prototype["getFirstUpload"] = function getFirstUpload(arg0, arg1) {
map = map.get(arg0);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(arg1);
}
if (value == null) {
value = closure_6;
}
let first = null;
if (value.length > 0) {
first = value[0];
}
return first;
};
prototype["hasAdditionalUploads"] = function hasAdditionalUploads(arg0, arg1) {
map = map.get(arg0);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(arg1);
}
if (value == null) {
value = closure_6;
}
let num = value.length;
if (num == null) {
num = 0;
}
return num > 1;
};
prototype["getUploads"] = function getUploads(id, ChannelMessage) {
map = map.get(id);
if (map == null) {
const _Map = Map;
map = new Map();
}
2026-07-20 16:05:17 +00:00
let value;
2026-07-29 08:29:29 +00:00
if (map != null) {
value = map.get(ChannelMessage);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (value == null) {
value = closure_6;
2026-07-20 16:05:17 +00:00
}
return value;
2026-07-29 08:29:29 +00:00
};
2026-08-13 07:00:46 +00:00
prototype["getUploadCount"] = function getUploadCount(channelId, ChannelMessage) {
2026-07-23 10:11:24 +00:00
map = map.get(channelId);
2026-07-29 08:29:29 +00:00
if (map == null) {
2026-07-20 16:05:17 +00:00
const _Map = Map;
map = new Map();
}
2026-07-29 08:29:29 +00:00
let value;
if (map != null) {
2026-08-13 07:00:46 +00:00
value = map.get(ChannelMessage);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (value == null) {
value = closure_6;
}
let num = value.length;
if (num == null) {
num = 0;
}
return num;
};
prototype["getUpload"] = function getUpload(channelId, id, ChannelMessage) {
2026-08-24 06:08:38 +00:00
closure_0 = id;
2026-07-29 08:29:29 +00:00
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(ChannelMessage);
}
if (value == null) {
value = closure_6;
}
return value.find((id) => id.id === closure_0);
};
prototype["findUpload"] = function findUpload(totalNumItems, ChannelMessage, closure_4) {
map = map.get(totalNumItems);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(ChannelMessage);
}
if (value == null) {
value = closure_6;
}
return value.find(closure_4);
};
UploadAttachmentStore.displayName = "UploadAttachmentStore";
2026-08-24 06:08:38 +00:00
const uploadAttachmentStore = new UploadAttachmentStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
UPLOAD_ATTACHMENT_POP_FILE: function handlePopFile(channelId) {
channelId = channelId.channelId;
2026-07-29 08:29:29 +00:00
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(DraftType.ChannelMessage);
}
if (value == null) {
value = closure_6;
}
const items = [...value];
2026-07-20 16:05:17 +00:00
items.shift();
2026-07-29 08:29:29 +00:00
let value1 = obj.get(channelId);
if (value1 == null) {
const _Map2 = Map;
value1 = new Map();
}
const result = value1.set(DraftType.ChannelMessage, items);
const result1 = obj.set(channelId, value1);
2026-07-20 16:05:17 +00:00
},
UPLOAD_ATTACHMENT_ADD_FILES: function handleAddFiles(arg0) {
({ files, channelId } = arg0);
2026-07-23 10:11:24 +00:00
({ draftType, allowOptimization: importDefault } = arg0);
2026-07-29 08:29:29 +00:00
let items;
let obj = map;
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(draftType);
}
if (value == null) {
value = closure_6;
}
items = [...value];
2026-07-20 16:05:17 +00:00
if (items.length + files.length > MAX_UPLOAD_COUNT) {
if (draftType !== DraftType.SlashCommand) {
if (draftType !== DraftType.ApplicationLauncherCommand) {
2026-07-29 08:29:29 +00:00
obj = { title: null, body: null };
const intl = channelId(items[3]).intl;
obj[0] = intl.string(channelId(items[3]).t.wOr6hB);
const intl2 = channelId(items[3]).intl;
obj = { limit: null };
obj[0] = tmp5;
obj[1] = intl2.formatToPlainString(channelId(items[3]).t["qqyp/e"], obj);
importDefault(items[2]).show(obj);
const obj4 = importDefault(items[2]);
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
const item = importDefault(items[4]).forEach(files, (file) => {
const cloudUpload = new channelId(items[5]).CloudUpload(file, channelId, items.length, closure_1);
2026-07-20 16:05:17 +00:00
items.push(cloudUpload);
});
2026-07-29 08:29:29 +00:00
let value1 = obj.get(channelId);
if (value1 == null) {
const _Map2 = Map;
value1 = new Map();
}
const result = value1.set(draftType, items);
const result1 = obj.set(channelId, value1);
2026-07-20 16:05:17 +00:00
},
UPLOAD_ATTACHMENT_UPDATE_FILE: function handleUpdateFile(arg0) {
2026-07-29 08:29:29 +00:00
({ channelId, id: require, filename: importDefault, description: dependencyMap, spoiler: DraftType, thumbnail: MAX_UPLOAD_COUNT, draftType } = arg0);
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(draftType);
}
if (value == null) {
value = closure_6;
}
const items = [...value];
const mapped = items.map((id) => {
2026-07-20 16:05:17 +00:00
if (id.id === closure_0) {
if (undefined !== closure_1) {
id.filename = closure_1;
}
2026-07-29 08:29:29 +00:00
if (undefined !== closure_3) {
id.spoiler = closure_3;
2026-07-20 16:05:17 +00:00
}
if (undefined !== closure_2) {
id.description = closure_2;
}
2026-07-29 08:29:29 +00:00
if (undefined !== closure_4) {
id.isThumbnail = closure_4;
2026-07-20 16:05:17 +00:00
}
}
return id;
2026-07-29 08:29:29 +00:00
});
let value1 = obj.get(channelId);
if (value1 == null) {
const _Map2 = Map;
value1 = new Map();
}
const result = value1.set(draftType, mapped);
const result1 = obj.set(channelId, value1);
2026-07-20 16:05:17 +00:00
},
UPLOAD_ATTACHMENT_REMOVE_FILE: function handleRemoveFile(id) {
2026-07-23 10:11:24 +00:00
({ channelId, id: require, draftType } = id);
2026-07-29 08:29:29 +00:00
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(draftType);
}
if (value == null) {
value = closure_6;
}
const items = [...value];
2026-07-23 10:11:24 +00:00
const findIndexResult = items.findIndex((closure_0) => {
2026-08-24 06:08:38 +00:00
let obj = closure_1_0(closure_1_2[6]);
2026-07-23 10:11:24 +00:00
obj = { uri: closure_0, filename: closure_0 };
return obj.doesImageMatchUpload(obj, closure_0);
2026-07-20 16:05:17 +00:00
});
if (findIndexResult > -1) {
const first = items.splice(findIndexResult, 1)[0];
first.removeFromMsgDraft();
2026-07-29 08:29:29 +00:00
let value1 = obj.get(channelId);
if (value1 == null) {
const _Map2 = Map;
value1 = new Map();
}
const result = value1.set(draftType, items);
const result1 = obj.set(channelId, value1);
2026-07-20 16:05:17 +00:00
}
},
UPLOAD_ATTACHMENT_REMOVE_FILES: function handleRemoveFiles(arg0) {
({ channelId, attachmentIds, draftType } = arg0);
2026-07-29 08:29:29 +00:00
let items;
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(draftType);
}
if (value == null) {
value = closure_6;
}
items = [...value];
2026-07-20 16:05:17 +00:00
const item = attachmentIds.forEach((arg0) => {
2026-08-24 06:08:38 +00:00
items = arg0;
2026-07-23 10:11:24 +00:00
const findIndexResult = items.findIndex((id) => closure_0 === id.id);
2026-07-20 16:05:17 +00:00
if (findIndexResult > -1) {
const first = items.splice(findIndexResult, 1)[0];
first.removeFromMsgDraft();
}
});
2026-07-29 08:29:29 +00:00
let value1 = obj.get(channelId);
if (value1 == null) {
const _Map2 = Map;
value1 = new Map();
}
const result = value1.set(draftType, items);
const result1 = obj.set(channelId, value1);
2026-07-20 16:05:17 +00:00
},
UPLOAD_ATTACHMENT_CLEAR_ALL_FILES: function handleClearAllFiles(channelId) {
2026-07-29 08:29:29 +00:00
channelId = channelId.channelId;
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
const result = map.set(channelId.draftType, []);
const result1 = map.set(channelId, map);
2026-07-20 16:05:17 +00:00
},
UPLOAD_ATTACHMENT_SET_UPLOADS: function handleSetUploads(channelId) {
2026-07-29 08:29:29 +00:00
channelId = channelId.channelId;
({ uploads, draftType } = channelId);
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
const result = map.set(draftType, uploads);
const result1 = map.set(channelId, map);
2026-07-20 16:05:17 +00:00
},
2026-07-29 08:29:29 +00:00
UPLOAD_ATTACHMENT_SET_FILE: function handleSetFile(arg0) {
({ channelId, id: require, file, draftType, allowOptimization } = arg0);
map = map.get(channelId);
if (map == null) {
const _Map = Map;
map = new Map();
}
let value;
if (map != null) {
value = map.get(draftType);
}
if (value == null) {
value = closure_6;
}
const items = [...value];
2026-07-20 16:05:17 +00:00
const found = items.filter((id) => id.id !== closure_0);
2026-08-24 06:08:38 +00:00
const cloudUpload = new set2.CloudUpload(file, channelId, undefined, allowOptimization);
2026-07-20 16:05:17 +00:00
found.push(cloudUpload);
2026-07-29 08:29:29 +00:00
let value1 = obj.get(channelId);
if (value1 == null) {
const _Map2 = Map;
value1 = new Map();
}
const result = value1.set(draftType, found);
const result1 = obj.set(channelId, value1);
2026-07-20 16:05:17 +00:00
}
});
2026-08-24 06:08:38 +00:00
let result = set.fileFinishedImporting("stores/UploadAttachmentStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default uploadAttachmentStore;