Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(notifications): initial textile, store notification set up #2908

Merged
merged 42 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
50506e9
feat(notifications): everything seems to be set up, need listeners fo…
Jekrimo Apr 18, 2022
724e472
feat(notifications): clean up code
Jekrimo Apr 18, 2022
5b7f82e
feat(notifications): clean up code
Jekrimo Apr 18, 2022
04414b4
feat(notifications): typo fix
Jekrimo Apr 18, 2022
19d8916
feat(notifications): wip on displaying new messages
Jekrimo Apr 20, 2022
f1a668a
feat(notifications): notification added on message recieved
Jekrimo Apr 20, 2022
fe78a57
feat(notifications): notification count and toggle alerts
Jekrimo Apr 22, 2022
84d706e
feat(notifications): adjust alerts comp to use notifications
Jekrimo Apr 23, 2022
3424b31
chore(jest): update snap
stavares843 Apr 22, 2022
33b76ca
feat(notifications): notifications fed to alerts, styles fixed
Jekrimo Apr 27, 2022
f457b67
feat(notifications): notifications able to be removed
Jekrimo Apr 27, 2022
ac27446
feat(notifications): notifications counter works
Jekrimo Apr 28, 2022
6dda393
feat(notifications): notification cleanup
Jekrimo Apr 28, 2022
d9b5d04
feat(notifications): fix translation
Jekrimo May 2, 2022
9e64465
feat(notifications): fix translation
Jekrimo May 2, 2022
91d6ace
feat(notifications): fixes from review
Jekrimo May 2, 2022
a2cd0ad
feat(notifications): skip test for now
Jekrimo May 2, 2022
576068b
feat(notifications): fix test, clean
Jekrimo May 3, 2022
1a661f7
feat(notifications): everything seems to be set up, need listeners fo…
Jekrimo Apr 18, 2022
833a05f
feat(notifications): clean up code
Jekrimo Apr 18, 2022
e71d777
feat(notifications): typo fix
Jekrimo Apr 18, 2022
a5341c5
feat(notifications): dont allow modal on no noti
Jekrimo May 4, 2022
143d5a7
feat(notifications): fix modal z-index
Jekrimo May 4, 2022
981678d
feat(notifications): sort by newest message first
Jekrimo May 4, 2022
8ad306f
feat(notifications): test fix
Jekrimo May 9, 2022
5e90b46
feat(notifications): everything seems to be set up, need listeners fo…
Jekrimo Apr 18, 2022
2bf9e7c
feat(notifications): clean up code
Jekrimo Apr 18, 2022
22384cb
feat(notifications): typo fix
Jekrimo Apr 18, 2022
fa1c46e
feat(notifications): notifications counter works
Jekrimo Apr 28, 2022
ef2faf5
feat(notifications): notification cleanup
Jekrimo Apr 28, 2022
602d586
feat(notifications): everything seems to be set up, need listeners fo…
Jekrimo Apr 18, 2022
1097c01
feat(notifications): clean up code
Jekrimo Apr 18, 2022
7fdfa9f
feat(notifications): typo fix
Jekrimo Apr 18, 2022
86289c8
feat(notifications): notifications fed to alerts, styles fixed
Jekrimo Apr 27, 2022
c5d5948
feat(notifications): fix after merge
Jekrimo May 10, 2022
17ac55a
feat(notifications): more old code somehow sneaking in
Jekrimo May 10, 2022
b858ee5
feat(notifications): breakage fixews
Jekrimo May 10, 2022
2f71078
feat(notifications): fix auto open on alerts modal
Jekrimo May 11, 2022
fc3e7d1
feat(notifications): no user select text, expand curson hover
Jekrimo May 11, 2022
ca1467e
feat(notifications): fix changes after review
Jekrimo May 12, 2022
8dc6b0c
feat(notifications): quick fix test
Jekrimo May 13, 2022
3805ab9
fix(editmessage): put switch translate into computed
Jekrimo May 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions components/views/navigation/toolbar/Toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,26 @@
/>
</div>
<div class="controls">
<UiComingSoon
v-if="!$device.isMobile"
:tooltipText="$t('coming_soon.alerts')"
:tooltipPosition="'bottom'"
data-cy="toolbar-alerts"
>
<div
class="has-tooltip has-tooltip-bottom has-tooltip-primary has-tooltip-hidden-touch"
@click="$data.showAlerts = !$data.showAlerts"
class="toggle-alerts has-tooltip has-tooltip-bottom has-tooltip-primary has-tooltip-hidden-touch"
@click='toggleAlerts'
>

<UiCircle
v-if='allUnseenNotifications.length'
class='notification-alert'
:size='15'
color='red'
type='icon'
:data='allUnseenNotifications.length'>
{{allUnseenNotifications.length}}
</UiCircle>
<bell-icon
size="1x"
:class="`control-icon ${showAlerts ? 'primary' : ''}`"
color="grey"
color="primary"
/>
</div>
</UiComingSoon>

<UiFloatingContainer
v-if="showAlerts"
Expand All @@ -53,7 +56,9 @@
:customStyles="$device.isMobile"
:toggleMethod="() => $data.showAlerts = false"
>
<ToolbarAlerts />
<ToolbarAlerts
:notifications='allUnseenNotifications'
/>
</UiFloatingContainer>
<div
:class="`has-tooltip has-tooltip-bottom has-tooltip-primary has-tooltip-hidden-touch control-button
Expand Down
11 changes: 11 additions & 0 deletions components/views/navigation/toolbar/Toolbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
margin: 0 @light-spacing;
}

.notification-alert {
position: fixed;
z-index: 1;
}

.toggle-alerts {
cursor: pointer;
user-select: none;
}

.controls {
&:extend(.background-semitransparent-light);
&:extend(.round-corners);
Expand Down Expand Up @@ -95,6 +105,7 @@
}

.alerts-floating-container {
z-index: 100;
&.side-open {
margin-right: 1.2rem;
}
Expand Down
38 changes: 23 additions & 15 deletions components/views/navigation/toolbar/Toolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { SearchQueryItem } from '~/types/search/search'
import { ModalWindows } from '~/store/ui/types'
import { TrackKind } from '~/libraries/WebRTC/types'
import { Friend } from '~/types/ui/friends'
import { RootState } from '~/types/store/store'

export default Vue.extend({
components: {
Expand Down Expand Up @@ -65,20 +66,24 @@ export default Vue.extend({
}
},
computed: {
...mapState([
'ui',
'audio',
'video',
'webrtc',
'conversation',
'groups',
'friends',
]),
...mapGetters('ui', ['showSidebar']),
selectedGroup() {
...mapState({
ui: (state) => (state as RootState).ui,
audio: (state) => (state as RootState).audio,
video: (state) => (state as RootState).video,
webrtc: (state) => (state as RootState).webrtc,
conversation: (state) => (state as RootState).conversation,
groups: (state) => (state as RootState).groups,
friends: (state) => (state as RootState).friends,
}),
...mapGetters('ui', ['showSidebar', 'allUnseenNotifications']),
selectedGroup(): string {
return this.$route.params.id // TODO: change with groupid - AP-400
},
recipient() {
recipient():
| Friend
| { textilePubkey: string; type: string }
| null
| undefined {
// It should not happen that someone tries to write to himself, but we should check
// anyway
const isMe =
Expand All @@ -101,10 +106,10 @@ export default Vue.extend({
)
},
showSearchResult: {
set(state) {
set(state): void {
this.$store.commit('ui/showSearchResult', state)
},
get() {
get(): boolean {
return this.ui.showSearchResult
},
},
Expand Down Expand Up @@ -137,6 +142,9 @@ export default Vue.extend({
state: { isOpen: true, group },
})
},
toggleAlerts() {
this.showAlerts = !this.showAlerts
},
isGroup(thing: any) {
return thing?.type && thing?.type === 'group'
},
Expand Down Expand Up @@ -176,7 +184,7 @@ export default Vue.extend({
* @description This updates the state to show/hide the specific modal you pass in
* @example toggleModal(ModalWindows.WALLET)
*/
toggleModal(modalName: keyof ModalWindows): void {
toggleModal(modalName: keyof ModalWindows) {
this.$store.commit('ui/toggleModal', {
name: modalName,
state: !this.ui.modals[modalName],
Expand Down
18 changes: 12 additions & 6 deletions components/views/navigation/toolbar/alerts/Alerts.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<div id="alerts">
<InteractablesButton
v-if='allUnseenNotifications.length'
size='small'
:action='clearNotifications'
style='margin-bottom:5px'
type='primary'
:text="$t('ui.clear_all')"/>
<ToolbarAlertsAlert
v-if="alerts.length !== 0"
v-for="alert in alerts"
:alert="alert"
:key="alert.id"
@sync="syncAlerts"
v-for="notification in notifications"
v-if="notifications.length && notification.state !== AlertState.READ"
:alert="notification"
:key="notification.id"
/>
<TypographySubtitle
v-if="!alerts.length"
v-if="!notifications.length "
:size="6"
:text="$t('alerts.caught_up')"
/>
Expand Down
22 changes: 16 additions & 6 deletions components/views/navigation/toolbar/alerts/Alerts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@

<script lang="ts">
import Vue, { PropType } from 'vue'
import { mapGetters, mapState } from 'vuex'
import { Alert, AlertState } from '~/libraries/ui/Alerts'
import { RootState } from '~/types/store/store'

export default Vue.extend({
data() {
return {
alerts: this.$Alerts.all,
}
props: {
notifications: {
type: Array as PropType<Array<Alert>>,
default: () => [],
required: false,
},
},
computed: {
...mapState({ ui: (state) => (state as RootState).ui }),
...mapGetters('ui', ['allUnseenNotifications']),
AlertState: () => AlertState,
},
methods: {
syncAlerts(alerts) {
this.$data.alerts = alerts
clearNotifications() {
this.$store.commit('ui/clearAllNotifications')
},
},
})
Expand Down
18 changes: 12 additions & 6 deletions components/views/navigation/toolbar/alerts/alert/Alert.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<div :class="`alert ${localAlert.state} ${hidden ? 'hidden' : 'shown'}`">
<div :class="`alert ${hidden ? 'hidden' : 'shown'}`">
<div>
<!--Optional alert image -->
<img v-if="localAlert.content.image" :src="localAlert.content.image" />
<img v-if="alert.content.image" :src="alert.content.image" />
<UiCircle
v-if="!alert.content.image"
type='random'
data-cy="circle-without-picture"
/>
</div>
<div>
<div class='info-holder'>
<div class="a-heading">
<!--Alert title-->
<TypographySubtitle :size="6" :text="localAlert.content.title" />
<TypographySubtitle :size="6" :text="alert.content.title" />
<!--Alert timestamp-->
<TypographyText
:text="$dayjs(localAlert.at).fromNow()"
:text="$dayjs(alert.at).fromNow()"
class="timestamp"
/>
</div>
<!--Alert description-->
<div class="description">
<TypographyText :text="localAlert.content.description" />
<TypographyText
:text="setTranslateText" />
</div>
</div>
<InteractablesClose :action="dismiss" />
Expand Down
8 changes: 7 additions & 1 deletion components/views/navigation/toolbar/alerts/alert/Alert.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
.alert {
transition: all @animation-speed ease;
opacity: 1;
width: 95%;
display: inline-flex;
flex-direction: row;
&:extend(.blur);
Expand All @@ -25,7 +26,7 @@
overflow: hidden;
padding: @light-spacing (@normal-spacing + @light-spacing) @light-spacing
@light-spacing;
justify-content: flex-start;
justify-content: center;
align-content: flex-start;
margin-bottom: @light-spacing;

Expand All @@ -43,6 +44,11 @@
vertical-align: top;
}

.info-holder {
width: 100%;
padding-left: 10px;
}

.a-heading {
display: flex;
&:extend(.full-width);
Expand Down
33 changes: 20 additions & 13 deletions components/views/navigation/toolbar/alerts/alert/Alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,42 @@
<script lang="ts">
import Vue, { PropType } from 'vue'

import { Alert, AlertState } from '~/libraries/ui/Alerts'
import { mapState } from 'vuex'
import VueI18n from 'vue-i18n'
import { Alert, AlertType } from '~/libraries/ui/Alerts'
import { RootState } from '~/types/store/store'

export default Vue.extend({
props: {
alert: {
type: Object as PropType<Alert>,
required: true,
default: {},
required: false,
default: () => {},
},
},
data() {
return {
localAlert: this.$props.alert,
hidden: false,
}
},
mounted() {
if (this.$props.alert.state !== AlertState.READ) {
const updated = this.$Alerts.mark(AlertState.READ, this.$props.alert.id)
this.$data.localAlert = updated
}
computed: {
...mapState({ ui: (state) => (state as RootState).ui }),
setTranslateText(): VueI18n.TranslateResult | undefined {
switch (this.alert?.type) {
case AlertType.DIRECT_MESSAGE: {
return this.$t('messaging.user_sent.user', {
user: this.alert.from,
msgType: this.alert.type,
})
}
}
return this.$t('user_sent_something.user')
},
},
methods: {
dismiss() {
this.$Alerts.delete(this.$props.alert.id)
this.$store.dispatch('ui/removeSeenNotification', this.alert.id)
this.$data.hidden = true
setTimeout(() => {
this.$emit('sync', this.$Alerts.all)
}, 250)
},
},
})
Expand Down
2 changes: 2 additions & 0 deletions libraries/Enums/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
FileIconsEnum,
FileAsideRouteEnum,
} from '~/libraries/Enums/types/files'
import { NotificationTypes } from '~/libraries/Enums/types/notification-types'

export {
KeybindingEnum,
Expand All @@ -29,6 +30,7 @@ export {
AddFriendEnum,
SocialAccountTypesEnum,
PlatformTypeEnum,
NotificationTypes,
FileSortEnum,
FileIconsEnum,
FileAsideRouteEnum,
Expand Down
10 changes: 10 additions & 0 deletions libraries/Enums/types/notification-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum NotificationTypes {
DIRECT_MESSAGE = 'directMessage',
GROUP_MESSAGE = 'groupMessage',
MENTIONS_NOTIFICATION = 'mentionNotification',
ACCOUNT_NOTIFICATION = 'accountNotification',
APPLICATION_NOTIFICATION = 'applicationNotification',
MISSED_CALL = 'missedCall',
FRIEND_REQUEST = 'friendRequest',
MISCELLANEOUS = 'miscellaneous',
}
Loading