Eduard Kuzmenko
3 years ago
10 changed files with 180 additions and 18 deletions
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
/* |
||||
* https://github.com/morethanwords/tweb
|
||||
* Copyright (C) 2019-2021 Eduard Kuzmenko |
||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||
*/ |
||||
|
||||
import tsNow from "../../helpers/tsNow"; |
||||
import appMessagesManager from "../../lib/appManagers/appMessagesManager"; |
||||
import { LangPackKey } from "../../lib/langPack"; |
||||
import { MUTE_UNTIL } from "../../lib/mtproto/mtproto_config"; |
||||
import RadioField from "../radioField"; |
||||
import Row, { RadioFormFromRows } from "../row"; |
||||
import { SettingSection } from "../sidebarLeft"; |
||||
import PopupPeer from "./peer"; |
||||
|
||||
export default class PopupMute extends PopupPeer { |
||||
constructor(peerId: PeerId) { |
||||
super('popup-mute', { |
||||
peerId, |
||||
titleLangKey: 'Notifications', |
||||
buttons: [{ |
||||
langKey: 'ChatList.Context.Mute', |
||||
callback: () => { |
||||
appMessagesManager.mutePeer(peerId, time === -1 ? MUTE_UNTIL : tsNow(true) + time); |
||||
} |
||||
}], |
||||
body: true |
||||
}); |
||||
|
||||
const ONE_HOUR = 3600; |
||||
const times: {time: number, langKey: LangPackKey}[] = [{ |
||||
time: ONE_HOUR, |
||||
langKey: 'ChatList.Mute.1Hour' |
||||
}, { |
||||
time: ONE_HOUR * 4, |
||||
langKey: 'ChatList.Mute.4Hours' |
||||
}, { |
||||
time: ONE_HOUR * 8, |
||||
langKey: 'ChatList.Mute.8Hours' |
||||
}, { |
||||
time: ONE_HOUR * 24, |
||||
langKey: 'ChatList.Mute.1Day' |
||||
}, { |
||||
time: ONE_HOUR * 24 * 3, |
||||
langKey: 'ChatList.Mute.3Days' |
||||
}, { |
||||
time: -1, |
||||
langKey: 'ChatList.Mute.Forever' |
||||
}]; |
||||
|
||||
const name = 'mute-time'; |
||||
const rows = times.map((time) => { |
||||
const row = new Row({ |
||||
radioField: new RadioField({ |
||||
langKey: time.langKey, |
||||
name, |
||||
value: '' + time.time |
||||
}) |
||||
}); |
||||
|
||||
return row; |
||||
}); |
||||
|
||||
let time: number; |
||||
const radioForm = RadioFormFromRows(rows, (value) => { |
||||
time = +value; |
||||
}); |
||||
|
||||
rows[rows.length - 1].radioField.checked = true; |
||||
|
||||
const section = new SettingSection({noShadow: true, noDelimiter: true}); |
||||
section.content.append(radioForm); |
||||
this.body.append(section.container); |
||||
|
||||
this.show(); |
||||
} |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
/* |
||||
* https://github.com/morethanwords/tweb |
||||
* Copyright (C) 2019-2021 Eduard Kuzmenko |
||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE |
||||
*/ |
||||
|
||||
.popup-mute { |
||||
.popup-container { |
||||
width: 16rem; |
||||
} |
||||
|
||||
.popup-body { |
||||
margin: 0 -.625rem; |
||||
} |
||||
|
||||
.sidebar-left-section { |
||||
margin-bottom: 0 !important; |
||||
padding: 0 !important; |
||||
|
||||
&-content { |
||||
margin: 0 !important; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue