diff options
author | Carlen White | 2023-01-19 23:41:54 -0500 |
---|---|---|
committer | Carlen White | 2023-01-19 23:41:54 -0500 |
commit | 954ff6ea8fc65bf40d10475dc144fe7d9a502493 (patch) | |
tree | 150db4d426a8f338f210e7884d6acd2942b7b5be | |
parent | bf89f52b80b8c42eb19536ab481cda59c4b2b412 (diff) | |
download | aur-954ff6ea8fc65bf40d10475dc144fe7d9a502493.tar.gz |
Patch to send unsent text in channels to file
Instead of unsent text being lost when there's a connection issue or closed for some other reason, a file is created and appended to in the log directory as `deadletter.log`
Exceptions are if the last tab is intentially closed, forcing F-Chat to immediately close.
-rw-r--r-- | PKGBUILD | 12 | ||||
-rw-r--r-- | deadletter.patch | 46 |
2 files changed, 56 insertions, 2 deletions
@@ -2,7 +2,7 @@ pkgname=fchat-rising-git _pkgname=fchat-rising pkgver=1.20.0 -pkgrel=1 +pkgrel=2 pkgdesc="The F-Chat 3.0 client from F-List modifed by MrStallion. Uses a system-wide electron instead of the built in." arch=('x86_64') url="https://github.com/mrstallion/fchat-rising" @@ -21,8 +21,13 @@ provides=('fchat-3.0') source=( "fchat::git+https://github.com/mrstallion/fchat-rising#tag=v$pkgver" 'local://fchat.desktop' + 'local://deadletter.patch' +) +sha256sums=( + 'SKIP' + 'eaa27f1eb8bd228e9bd11a1cd068f30b3129abce85ab9f275de34dbf60ba8fba' + '249e4e9263098b64399ccc8bcd9c64dca5b3858c244c061ccc2ebe37f32cb258' ) -sha256sums=('SKIP' 'eaa27f1eb8bd228e9bd11a1cd068f30b3129abce85ab9f275de34dbf60ba8fba') _ensure_local_nvm() { # https://wiki.archlinux.org/title/Node.js_package_guidelines#Using_nvm @@ -37,6 +42,9 @@ _ensure_local_nvm() { } prepare() { + cd $srcdir/fchat/ + git apply $srcdir/deadletter.patch + cd $srcdir echo "Init NVM..." _ensure_local_nvm echo "Install Node v16..." diff --git a/deadletter.patch b/deadletter.patch new file mode 100644 index 000000000000..7e19786e2802 --- /dev/null +++ b/deadletter.patch @@ -0,0 +1,46 @@ +diff --git a/chat/conversations.ts b/chat/conversations.ts +index 148ebc9..00220a2 100644 +--- a/chat/conversations.ts ++++ b/chat/conversations.ts +@@ -13,6 +13,8 @@ import throat from 'throat'; + import Bluebird from 'bluebird'; + import log from 'electron-log'; + import isChannel = Interfaces.isChannel; ++import path from 'path'; ++import fs from 'fs'; + + function createMessage(this: any, type: MessageType, sender: Character, text: string, time?: Date): Message { + if(type === MessageType.Message && isAction(text)) { +@@ -746,6 +748,32 @@ export default function(this: any): Interfaces.State { + state.selectedConversation.lastRead = state.selectedConversation.messages[state.selectedConversation.messages.length - 1]; + }); + const connection = core.connection; ++ connection.onEvent('closed', (_) => { ++ log.warn('Connection is closing. We are going to panic-save all channels containing unsent text.'); ++ let logLocation = core.state.generalSettings!.logDirectory; ++ fs.mkdirSync(logLocation, {recursive: true}); ++ ++ let collectedLogs: string[][] = []; ++ for (let channelConversation of state.channelConversations) { ++ let conversationName = channelConversation.channel.name; ++ let enteredText = channelConversation.enteredText; ++ if (enteredText != '') { ++ collectedLogs.push([conversationName, enteredText]); ++ } ++ } ++ if (collectedLogs.length > 0) { ++ let deadLetterPath = path.join(logLocation, 'deadletter.log'); ++ log.warn(`We found unsent messages. They will be written to \`${deadLetterPath}\``); ++ let deadLetterFile = fs.openSync(deadLetterPath, 'a'); ++ let now = new Date(); ++ fs.writeSync(deadLetterFile, `### ${now} ###\n`); ++ for (let [conversationName, enteredText] of collectedLogs) { ++ fs.writeSync(deadLetterFile, `=== ${conversationName} ===\n${enteredText}\n`); ++ } ++ fs.closeSync(deadLetterFile); ++ } ++ ++ }); + connection.onEvent('connecting', async(isReconnect) => { + state.channelConversations = []; + state.channelMap = {}; |