make file transfer initiate automatically
This commit is contained in:
Vendored
+41
-14
@@ -2244,7 +2244,9 @@
|
||||
searchTerm
|
||||
];
|
||||
this.storageModel.write(suggestionPath, "");
|
||||
if (!this.coreViewModel.boardFilterStringSuggestions.value.has(searchTerm)) {
|
||||
if (!this.coreViewModel.boardFilterStringSuggestions.value.has(
|
||||
searchTerm
|
||||
)) {
|
||||
this.coreViewModel.boardFilterStringSuggestions.add(searchTerm);
|
||||
}
|
||||
const lastSearchPath = this.getLastSearchPath();
|
||||
@@ -2517,6 +2519,7 @@
|
||||
reloadAppButton: "Reload App",
|
||||
fileVersionLabel: "Version",
|
||||
searchLabel: "Search",
|
||||
waitingLabel: "Waiting...",
|
||||
restoreConnection: "Restore connection"
|
||||
},
|
||||
regional: {
|
||||
@@ -2566,7 +2569,6 @@
|
||||
selectionDescription: "Select the data that you want to transfer.",
|
||||
dataEntryDescription: "Enter this data on the other device.",
|
||||
dataEntryInputDescription: "Enter the data displayed on the other device.",
|
||||
readyToReceiveDescription: "Click 'send' on the other device.",
|
||||
notConnectedError: "You are not connected to any server.",
|
||||
///
|
||||
fromThisDeviceButton: "From this device",
|
||||
@@ -2707,6 +2709,7 @@
|
||||
reloadAppButton: "Neu laden",
|
||||
fileVersionLabel: "Version",
|
||||
searchLabel: "Suche",
|
||||
waitingLabel: "Warten...",
|
||||
restoreConnection: "Verbindung wiederherstellen"
|
||||
},
|
||||
regional: {
|
||||
@@ -2753,7 +2756,6 @@
|
||||
selectionDescription: "W\xE4hle die Daten aus, die du \xFCbertragen m\xF6chtest.",
|
||||
dataEntryDescription: "Gib diese Informationen auf dem anderen Ger\xE4t ein.",
|
||||
dataEntryInputDescription: "Gib die auf dem anderen Ger\xE4t angezeigten Informationen ein.",
|
||||
readyToReceiveDescription: "Klicke auf dem anderen Ger\xE4t auf 'Senden'.",
|
||||
notConnectedError: "Du bist mit keinem Server verbunden.",
|
||||
fromThisDeviceButton: "Von diesem Ger\xE4t",
|
||||
toThisDeviceButton: "An dieses Ger\xE4t",
|
||||
@@ -2878,6 +2880,7 @@
|
||||
reloadAppButton: "Recargar app",
|
||||
fileVersionLabel: "Versi\xF3n",
|
||||
searchLabel: "Buscar",
|
||||
waitingLabel: "Esperando...",
|
||||
restoreConnection: "Conectar de nuevo"
|
||||
},
|
||||
regional: {
|
||||
@@ -2924,7 +2927,6 @@
|
||||
selectionDescription: "Selecciona los datos que quieres transferir.",
|
||||
dataEntryDescription: "Introduce estos datos en el otro dispositivo.",
|
||||
dataEntryInputDescription: "Introduce los datos mostrados en el otro dispositivo.",
|
||||
readyToReceiveDescription: "Haz clic en 'enviar' en el otro dispositivo.",
|
||||
notConnectedError: "No est\xE1s conectado a ning\xFAn servidor.",
|
||||
fromThisDeviceButton: "Desde este dispositivo",
|
||||
toThisDeviceButton: "A este dispositivo",
|
||||
@@ -3104,11 +3106,14 @@
|
||||
this.hasUnreadMessages.value = hasUnreadMessages;
|
||||
};
|
||||
this.subscribeReadStatus = () => {
|
||||
createProxyState([this.selectedPage, this.chatListViewModel.selectedChat], () => {
|
||||
createProxyState(
|
||||
[this.selectedPage, this.chatListViewModel.selectedChat],
|
||||
() => {
|
||||
if (this.chatListViewModel.selectedChat.value != this) return;
|
||||
if (this.selectedPage.value != "messages" /* Messages */) return;
|
||||
this.setReadStatus(false);
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
this.storageModel = storageModel2;
|
||||
this.chatModel = chatModel;
|
||||
@@ -5147,6 +5152,7 @@
|
||||
this.connectToAddress(this.serverAddressInput.value);
|
||||
};
|
||||
this.connectToAddress = (address) => {
|
||||
console.log(address);
|
||||
this.connectionModel.connect(address);
|
||||
};
|
||||
this.disconnect = () => {
|
||||
@@ -5282,6 +5288,7 @@
|
||||
this.showTransferDataModal = () => {
|
||||
this.presentedModal.value = 2 /* TransferDataDisplay */;
|
||||
this.getTransferData();
|
||||
this.fileTransferModel.prepareToSend();
|
||||
};
|
||||
this.initiateTransfer = () => {
|
||||
this.presentedModal.value = 3 /* TransferDisplay */;
|
||||
@@ -5316,6 +5323,9 @@
|
||||
this.fileTransferModel.fileHandlerManager.addHandler(
|
||||
this.handleReceivedFile
|
||||
);
|
||||
this.fileTransferModel.readyToSendHandlerManager.addHandler(
|
||||
() => this.initiateTransfer()
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5463,11 +5473,10 @@
|
||||
), /* @__PURE__ */ createElement(
|
||||
"button",
|
||||
{
|
||||
class: "primary flex",
|
||||
"on:click": fileTransferViewModel2.initiateTransfer
|
||||
disabled: true,
|
||||
class: "flex"
|
||||
},
|
||||
translations.dataTransferModal.sendButton,
|
||||
/* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_forward")
|
||||
translations.general.waitingLabel
|
||||
))));
|
||||
}
|
||||
function TransferDisplayModal(fileTransferViewModel2) {
|
||||
@@ -5554,7 +5563,7 @@
|
||||
[fileTransferViewModel2.presentedModal],
|
||||
() => fileTransferViewModel2.presentedModal.value == 5 /* ReceptionDisplay */
|
||||
);
|
||||
return /* @__PURE__ */ createElement("div", { class: "modal", "toggle:open": isPresented }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("main", null, /* @__PURE__ */ createElement("h2", null, translations.dataTransferModal.transferDataHeadline), /* @__PURE__ */ createElement("p", { class: "secondary" }, translations.dataTransferModal.readyToReceiveDescription), /* @__PURE__ */ createElement(
|
||||
return /* @__PURE__ */ createElement("div", { class: "modal", "toggle:open": isPresented }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("main", null, /* @__PURE__ */ createElement("h2", null, translations.dataTransferModal.transferDataHeadline), /* @__PURE__ */ createElement(
|
||||
"p",
|
||||
{
|
||||
class: "secondary",
|
||||
@@ -5573,10 +5582,12 @@
|
||||
}
|
||||
|
||||
// src/Model/Global/fileTransferModel.ts
|
||||
var FileTransferModel = class {
|
||||
var FileTransferModel = class _FileTransferModel {
|
||||
// init
|
||||
constructor(storageModel2, connectionModel2) {
|
||||
this.fileHandlerManager = new HandlerManager();
|
||||
this.readyToSendHandlerManager = new HandlerManager();
|
||||
this.direction = 0 /* Send */;
|
||||
// general
|
||||
this.generateTransferData = () => {
|
||||
const transferData = {
|
||||
@@ -5586,15 +5597,29 @@
|
||||
this.transferData = transferData;
|
||||
return transferData;
|
||||
};
|
||||
this.prepareToSend = () => {
|
||||
this.direction = 0 /* Send */;
|
||||
this.connectionModel.addChannel(this.transferData.channel);
|
||||
};
|
||||
this.prepareToReceive = (transferData) => {
|
||||
this.direction = 1 /* Receive */;
|
||||
this.connectionModel.addChannel(transferData.channel);
|
||||
this.transferData = transferData;
|
||||
this.connectionModel.sendPlainMessage(
|
||||
transferData.channel,
|
||||
_FileTransferModel.READY_MESSAGE
|
||||
);
|
||||
};
|
||||
// handlers
|
||||
this.handleMessage = (data) => {
|
||||
console.log(this.transferData);
|
||||
if (data.messageChannel != this.transferData.channel) return;
|
||||
if (data.messageBody == _FileTransferModel.READY_MESSAGE && this.direction == 0 /* Send */) {
|
||||
console.log("TRIGGER");
|
||||
this.readyToSendHandlerManager.trigger(true);
|
||||
}
|
||||
if (this.transferData == void 0) return;
|
||||
if (data.messageBody == void 0) return;
|
||||
if (data.messageChannel != this.transferData.channel) return;
|
||||
this.handleFile(data.messageBody);
|
||||
};
|
||||
this.handleFile = async (encryptedFileData) => {
|
||||
@@ -5603,7 +5628,6 @@
|
||||
encryptedFileData,
|
||||
this.transferData.key
|
||||
);
|
||||
console.log(decrypted);
|
||||
const parsed = parse(decrypted);
|
||||
const isFileData = checkMatchesObjectStructure(
|
||||
parsed,
|
||||
@@ -5653,6 +5677,9 @@
|
||||
this.handleMessage
|
||||
);
|
||||
}
|
||||
static {
|
||||
this.READY_MESSAGE = "ready";
|
||||
}
|
||||
};
|
||||
var FileDataReference = {
|
||||
path: [""],
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@types/uuid": "^10.0.0",
|
||||
"bloatless-react": "^1.3.10",
|
||||
"bloatless-react": "^1.3.11",
|
||||
"esbuild": "^0.23.0",
|
||||
"udn-frontend": "^1.0.9",
|
||||
"uuid": "^10.0.0"
|
||||
|
||||
@@ -17,9 +17,13 @@ export default class FileTransferModel {
|
||||
storageModel: StorageModel;
|
||||
connectionModel: ConnectionModel;
|
||||
|
||||
static READY_MESSAGE = "ready";
|
||||
|
||||
// data
|
||||
transferData: TransferData | undefined;
|
||||
fileHandlerManager: HandlerManager<string> = new HandlerManager();
|
||||
readyToSendHandlerManager: HandlerManager<boolean> = new HandlerManager();
|
||||
direction: TransferDirections = TransferDirections.Send;
|
||||
|
||||
// general
|
||||
generateTransferData = (): TransferData => {
|
||||
@@ -31,16 +35,36 @@ export default class FileTransferModel {
|
||||
return transferData;
|
||||
};
|
||||
|
||||
prepareToReceive = (transferData: TransferData) => {
|
||||
prepareToSend = (): void => {
|
||||
this.direction = TransferDirections.Send;
|
||||
this.connectionModel.addChannel(this.transferData.channel);
|
||||
};
|
||||
|
||||
prepareToReceive = (transferData: TransferData): void => {
|
||||
this.direction = TransferDirections.Receive;
|
||||
|
||||
this.connectionModel.addChannel(transferData.channel);
|
||||
this.transferData = transferData;
|
||||
this.connectionModel.sendPlainMessage(
|
||||
transferData.channel,
|
||||
FileTransferModel.READY_MESSAGE,
|
||||
);
|
||||
};
|
||||
|
||||
// handlers
|
||||
handleMessage = (data: Message): void => {
|
||||
console.log(this.transferData);
|
||||
if (data.messageChannel != this.transferData.channel) return;
|
||||
if (
|
||||
data.messageBody == FileTransferModel.READY_MESSAGE &&
|
||||
this.direction == TransferDirections.Send
|
||||
) {
|
||||
console.log("TRIGGER");
|
||||
this.readyToSendHandlerManager.trigger(true);
|
||||
}
|
||||
|
||||
if (this.transferData == undefined) return;
|
||||
if (data.messageBody == undefined) return;
|
||||
if (data.messageChannel != this.transferData.channel) return;
|
||||
|
||||
this.handleFile(data.messageBody);
|
||||
};
|
||||
@@ -52,7 +76,6 @@ export default class FileTransferModel {
|
||||
encryptedFileData,
|
||||
this.transferData.key,
|
||||
);
|
||||
console.log(decrypted);
|
||||
|
||||
const parsed: any = parse(decrypted);
|
||||
const isFileData: boolean = checkMatchesObjectStructure(
|
||||
@@ -131,3 +154,8 @@ export const FileDataReference: FileData = {
|
||||
path: [""],
|
||||
body: "",
|
||||
};
|
||||
|
||||
export enum TransferDirections {
|
||||
Send,
|
||||
Receive,
|
||||
}
|
||||
|
||||
@@ -281,12 +281,8 @@ function TransferDataDisplayModal(
|
||||
>
|
||||
{translations.general.backButton}
|
||||
</button>
|
||||
<button
|
||||
class="primary flex"
|
||||
on:click={fileTransferViewModel.initiateTransfer}
|
||||
>
|
||||
{translations.dataTransferModal.sendButton}
|
||||
<span class="icon">arrow_forward</span>
|
||||
<button disabled class="flex">
|
||||
{translations.general.waitingLabel}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -461,13 +457,6 @@ function DataReceptionModal(fileTransferViewModel: FileTransferViewModel) {
|
||||
{translations.dataTransferModal.transferDataHeadline}
|
||||
</h2>
|
||||
|
||||
<p class="secondary">
|
||||
{
|
||||
translations.dataTransferModal
|
||||
.readyToReceiveDescription
|
||||
}
|
||||
</p>
|
||||
|
||||
<p
|
||||
class="secondary"
|
||||
subscribe:innerText={
|
||||
|
||||
@@ -25,7 +25,7 @@ export function TaskSettingsModal(taskViewModel: TaskViewModel) {
|
||||
};
|
||||
|
||||
return (
|
||||
<div class="modal" open>
|
||||
<div class="modal" open metakey:s={taskViewModel.closeAndSave}>
|
||||
<div>
|
||||
<main>
|
||||
<h2>{translations.chatPage.task.taskSettingsHeadline}</h2>
|
||||
|
||||
@@ -21,6 +21,7 @@ const englishTranslations = {
|
||||
|
||||
fileVersionLabel: "Version",
|
||||
searchLabel: "Search",
|
||||
waitingLabel: "Waiting...",
|
||||
|
||||
restoreConnection: "Restore connection",
|
||||
},
|
||||
@@ -89,7 +90,6 @@ const englishTranslations = {
|
||||
dataEntryDescription: "Enter this data on the other device.",
|
||||
dataEntryInputDescription:
|
||||
"Enter the data displayed on the other device.",
|
||||
readyToReceiveDescription: "Click 'send' on the other device.",
|
||||
|
||||
notConnectedError: "You are not connected to any server.",
|
||||
|
||||
@@ -298,6 +298,7 @@ const allTranslations: { [language: string]: typeof englishTranslations } = {
|
||||
|
||||
fileVersionLabel: "Version",
|
||||
searchLabel: "Suche",
|
||||
waitingLabel: "Warten...",
|
||||
|
||||
restoreConnection: "Verbindung wiederherstellen",
|
||||
},
|
||||
@@ -362,8 +363,6 @@ const allTranslations: { [language: string]: typeof englishTranslations } = {
|
||||
"Gib diese Informationen auf dem anderen Gerät ein.",
|
||||
dataEntryInputDescription:
|
||||
"Gib die auf dem anderen Gerät angezeigten Informationen ein.",
|
||||
readyToReceiveDescription:
|
||||
"Klicke auf dem anderen Gerät auf 'Senden'.",
|
||||
|
||||
notConnectedError: "Du bist mit keinem Server verbunden.",
|
||||
|
||||
@@ -543,6 +542,7 @@ const allTranslations: { [language: string]: typeof englishTranslations } = {
|
||||
|
||||
fileVersionLabel: "Versión",
|
||||
searchLabel: "Buscar",
|
||||
waitingLabel: "Esperando...",
|
||||
|
||||
restoreConnection: "Conectar de nuevo",
|
||||
},
|
||||
@@ -607,8 +607,6 @@ const allTranslations: { [language: string]: typeof englishTranslations } = {
|
||||
"Introduce estos datos en el otro dispositivo.",
|
||||
dataEntryInputDescription:
|
||||
"Introduce los datos mostrados en el otro dispositivo.",
|
||||
readyToReceiveDescription:
|
||||
"Haz clic en 'enviar' en el otro dispositivo.",
|
||||
|
||||
notConnectedError: "No estás conectado a ningún servidor.",
|
||||
|
||||
|
||||
@@ -116,12 +116,15 @@ export default class ChatViewModel {
|
||||
};
|
||||
|
||||
subscribeReadStatus = (): void => {
|
||||
React.createProxyState([this.selectedPage, this.chatListViewModel.selectedChat], () => {
|
||||
React.createProxyState(
|
||||
[this.selectedPage, this.chatListViewModel.selectedChat],
|
||||
() => {
|
||||
if (this.chatListViewModel.selectedChat.value != this) return;
|
||||
if (this.selectedPage.value != ChatPageType.Messages) return;
|
||||
this.setReadStatus(false);
|
||||
})
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
|
||||
@@ -52,6 +52,7 @@ export default class ConnectionViewModel {
|
||||
};
|
||||
|
||||
connectToAddress = (address: string): void => {
|
||||
console.log(address);
|
||||
this.connectionModel.connect(address);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ export default class CoreViewModel {
|
||||
|
||||
// SUGGESTIONS
|
||||
// boards & tasks
|
||||
boardSearchSuggestions: React.ListState<string> = new React.ListState();
|
||||
boardFilterStringSuggestions: React.ListState<string> =
|
||||
new React.ListState();
|
||||
|
||||
taskCategorySuggestions: React.ListState<string> = new React.ListState();
|
||||
taskStatusSuggestions: React.ListState<string> = new React.ListState();
|
||||
|
||||
@@ -128,6 +128,7 @@ export default class FileTransferViewModel {
|
||||
showTransferDataModal = (): void => {
|
||||
this.presentedModal.value = FileTransferModal.TransferDataDisplay;
|
||||
this.getTransferData();
|
||||
this.fileTransferModel.prepareToSend();
|
||||
};
|
||||
|
||||
initiateTransfer = (): void => {
|
||||
@@ -176,6 +177,10 @@ export default class FileTransferViewModel {
|
||||
this.fileTransferModel.fileHandlerManager.addHandler(
|
||||
this.handleReceivedFile,
|
||||
);
|
||||
|
||||
this.fileTransferModel.readyToSendHandlerManager.addHandler(() =>
|
||||
this.initiateTransfer(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ export default class NotificationViewModel {
|
||||
(chat) => chat.chatModel.info.primaryChannel == notification.chat,
|
||||
);
|
||||
chat.open();
|
||||
chat.selectedPage.value = ChatPageType.Messages;
|
||||
};
|
||||
|
||||
// loop
|
||||
|
||||
@@ -121,8 +121,12 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
searchTerm,
|
||||
];
|
||||
this.storageModel.write(suggestionPath, "");
|
||||
if (!this.coreViewModel.boardSearchSuggestions.value.has(searchTerm)) {
|
||||
this.coreViewModel.boardSearchSuggestions.add(searchTerm);
|
||||
if (
|
||||
!this.coreViewModel.boardFilterStringSuggestions.value.has(
|
||||
searchTerm,
|
||||
)
|
||||
) {
|
||||
this.coreViewModel.boardFilterStringSuggestions.add(searchTerm);
|
||||
}
|
||||
|
||||
const lastSearchPath: string[] = this.getLastSearchPath();
|
||||
@@ -221,7 +225,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
loadSearchSuggestions = (): void => {
|
||||
const dirPath: string[] = this.getPreviousSearchesPath();
|
||||
const searches: string[] = this.storageModel.list(dirPath);
|
||||
this.coreViewModel.boardSearchSuggestions.add(...searches);
|
||||
this.coreViewModel.boardFilterStringSuggestions.add(...searches);
|
||||
};
|
||||
|
||||
restoreSearch = (): void => {
|
||||
@@ -290,7 +294,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
this.taskViewModels,
|
||||
this.filteredTaskViewModels,
|
||||
TaskViewModel.getStringsForFilter,
|
||||
this.coreViewModel.boardSearchSuggestions,
|
||||
this.coreViewModel.boardFilterStringSuggestions,
|
||||
);
|
||||
this.searchViewModel.appliedQuery.subscribeSilent((newQuery) => {
|
||||
this.handleNewSearch(newQuery);
|
||||
|
||||
@@ -164,6 +164,8 @@ export default class TaskPageViewModel {
|
||||
|
||||
this.chatViewModel = chatViewModel;
|
||||
|
||||
this.loadData();
|
||||
|
||||
// handlers
|
||||
boardModel.boardHandlerManager.addHandler(
|
||||
(boardInfoFileContent: BoardInfoFileContent) => {
|
||||
|
||||
@@ -101,7 +101,8 @@ export default class TaskViewModel {
|
||||
this.loadTaskData();
|
||||
};
|
||||
|
||||
closeAndSave = (): void => {
|
||||
closeAndSave = (e: Event): void => {
|
||||
e.preventDefault();
|
||||
this.close();
|
||||
this.save();
|
||||
};
|
||||
@@ -234,7 +235,6 @@ export default class TaskViewModel {
|
||||
static getStringsForFilter = (taskViewModel: TaskViewModel): string[] => {
|
||||
return [
|
||||
taskViewModel.task.name,
|
||||
taskViewModel.task.description ?? "",
|
||||
taskViewModel.task.category ?? "",
|
||||
taskViewModel.task.status ?? "",
|
||||
taskViewModel.task.priority ?? "",
|
||||
|
||||
Reference in New Issue
Block a user