Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into sebin/task/#2012-ad…
Browse files Browse the repository at this point in the history
…d-menu-to-copy-message-text
  • Loading branch information
SebinSong committed Jun 4, 2024
2 parents ac71bb3 + 20cccfd commit db605f6
Show file tree
Hide file tree
Showing 15 changed files with 689 additions and 295 deletions.
67 changes: 61 additions & 6 deletions frontend/assets/style/components/_custom-markdowns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
white-space: initial;
-webkit-touch-callout: none;

&.c-replying {
border-left: 2px;
border-color: #dbdbdb; // var(--text_1);
border-style: none none none solid;
font-size: 0.75rem;
color: var(--text_1);
font-style: italic;
padding-left: 0.25rem;
white-space: pre-line;

&:hover {
cursor: pointer;
color: var(--text_2);
border-color: var(--text_1); // var(--text_2);
}

.c-member-mention,
.c-channel-mention {
background-color: transparent;
}
}

code {
display: inline-block;
border-radius: $radius;
Expand Down Expand Up @@ -34,32 +56,59 @@
margin-right: 1px;
}

ul {
ul,
ol {
margin: 0.75rem 0;
}

ul li {
position: relative;
display: block;
padding: 0 0 0.2rem 1.25rem;
padding: 0 0 0.2rem 1.125rem;

&:not(:last-child) {
margin-bottom: 0.5rem;
margin-bottom: 0.25rem;
}

&::before {
content: "";
position: absolute;
display: block;
left: 0.2rem;
top: 0.5rem;
width: 0.5rem;
height: 0.5rem;
top: 0.6rem;
width: 0.4rem;
height: 0.4rem;
border-radius: 50%;
background-color: $text_0;
}
}

ol li {
position: relative;
padding-bottom: 0.2rem;
margin-left: 1.125rem;

&:not(:last-child) {
margin-bottom: 0.25rem;
}
}

li {
// style correction for a nested sub-list within <li></li>.
> ul,
> ol {
margin-bottom: 0;
}

> ul li::before {
background-color: rgba(0, 0, 0, 0);
border: 1px solid $text_0;
top: 0.6rem;
width: 0.4rem;
height: 0.4rem;
}
}

blockquote {
position: relative;
padding-left: 1rem;
Expand All @@ -81,4 +130,10 @@
.link {
border-bottom-color: currentColor;
}

.c-edited {
margin-left: 0.2rem;
font-size: 0.7rem;
color: var(--text_1);
}
}
3 changes: 2 additions & 1 deletion frontend/common/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ export default function L (

export function LError (error: Error): {|reportError: any|} {
let url = `/app/dashboard?modal=UserSettingsModal&tab=application-logs&errorMsg=${encodeURI(error.message)}`
const target = !sbp('state/vuex/state').loggedIn ? 'target="_blank"' : ''
if (!sbp('state/vuex/state').loggedIn) {
url = 'https://github.com/okTurtles/group-income/issues'
}
return {
reportError: L('"{errorMsg}". You can {a_}report the error{_a}.', {
errorMsg: error.message,
'a_': `<a class="link" target="_blank" href="${url}">`,
'a_': `<a class="link" ${target} href="${url}">`,
'_a': '</a>'
})
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import sbp from '@sbp/sbp'
import '@sbp/okturtles.data'
import '@sbp/okturtles.events'
import '@sbp/okturtles.eventqueue'
import IdleVue from 'idle-vue'
import { mapMutations, mapGetters, mapState } from 'vuex'
import 'wicg-inert'
import '@model/captureLogs.js'
Expand Down Expand Up @@ -315,6 +316,9 @@ async function startApp () {
const databaseKey = `chelonia/persistentActions/${sbp('state/vuex/getters').ourIdentityContractId}`
sbp('chelonia.persistentActions/configure', { databaseKey })
await sbp('chelonia.persistentActions/load')

// NOTE: should set IdleVue plugin here because state could be replaced while logging in
Vue.use(IdleVue, { store, idleTime: 2 * 60 * 1000 }) // 2 mins of idle config
})
sbp('okTurtles.events/on', LOGOUT, () => {
this.ephemeral.finishedLogin = 'no'
Expand Down
43 changes: 27 additions & 16 deletions frontend/model/captureLogs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sbp from '@sbp/sbp'
import { CAPTURED_LOGS, SET_APP_LOGS_FILTER } from '~/frontend/utils/events.js'
import CircularList from '~/shared/CircularList.js'
import { L } from '@common/common.js'

/*
- giConsole/[username]/entries - the stored log entries.
Expand Down Expand Up @@ -123,24 +124,34 @@ function clearLogs () {
}

// Util to download all stored logs so far.
function downloadLogs (elLink: Object): void {
const filename = 'gi_logs.json'
function downloadOrShareLogs (actionType: 'share' | 'download', elLink?: HTMLAnchorElement): any {
const filename = 'gi_logs.json.txt'
const mimeType = 'text/plain'

const file = new Blob([JSON.stringify({
const blob = new Blob([JSON.stringify({
// Add instructions in case the user opens the file.
_instructions: 'GROUP INCOME - Application Logs - Attach this file when reporting an issue: https://github.com/okTurtles/group-income/issues',
ua: navigator.userAgent,
logs: getLogger().entries.toArray()
}, undefined, 2)], { type: 'application/json' })

const url = URL.createObjectURL(file)
elLink.href = url
elLink.download = filename
elLink.click()
setTimeout(() => {
elLink.href = '#'
URL.revokeObjectURL(url)
}, 0)
}, undefined, 2)], { type: mimeType })

if (actionType === 'download') {
if (!elLink) { return }

const url = URL.createObjectURL(blob)
elLink.href = url
elLink.download = filename
elLink.click()
setTimeout(() => {
elLink.href = '#'
URL.revokeObjectURL(url)
}, 0)
} else {
return window.navigator.share({
files: [new File([blob], filename, { type: blob.type })],
title: L('Application Logs')
})
}
}

function getLogger (): Object {
Expand Down Expand Up @@ -174,9 +185,9 @@ function setAppLogsFilter (filter: Array<string>) {
window.addEventListener('beforeunload', event => sbp('appLogs/save'))

sbp('sbp/selectors/register', {
'appLogs/download' (elLink) { downloadLogs(elLink) },
'appLogs/downloadOrShare': downloadOrShareLogs,
'appLogs/get' () { return getLogger()?.entries?.toArray() ?? [] },
'appLogs/save' () { getLogger()?.save() },
'appLogs/pauseCapture' ({ wipeOut }) { captureLogsPause({ wipeOut }) },
'appLogs/startCapture' (identityContractID) { captureLogsStart(identityContractID) }
'appLogs/pauseCapture': captureLogsPause,
'appLogs/startCapture': captureLogsStart
})
18 changes: 16 additions & 2 deletions frontend/views/components/sounds/Background.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@ export default ({
sbp('okTurtles.events/on', MESSAGE_RECEIVE, this.playMessageReceive)
sbp('okTurtles.events/on', MESSAGE_SEND, this.playMessageSend)
},
computed: {
isAppIdle () {
// NOTE: idle-vue plugin will provide this.isAppIdle
// but sometimes it returns undefined, so redefine here
return this.$store.state.idleVue?.isIdle
}
},
methods: {
shouldPlay () {
return document.hidden || this.isAppIdle
},
playMessageReceive () {
this.$refs.msgReceive.play()
if (this.shouldPlay()) {
this.$refs.msgReceive.play()
}
},
playMessageSend () {
this.$refs.msgSend.play()
if (this.shouldPlay()) {
this.$refs.msgSend.play()
}
}
}
}: Object)
Expand Down
Loading

0 comments on commit db605f6

Please sign in to comment.